PHP code example of tamedevelopers / file

1. Go to this page and download the library: Download tamedevelopers/file library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tamedevelopers / file example snippets




use Tamedevelopers\File\File;

$file = new File();



$file = new Tamedevelopers\File\File();

$file = TameFile();

"scripts": {
    "pre-autoload-dump": "Aws\\Script\\Composer\\Composer::removeUnusedServices"
},
"extra": {
    "aws/aws-sdk-php": [
        "Ec2",
        "CloudWatch"
    ]
}

$file = File::name('html_input_name');

$file->getMessage();


// This will change the message text
$file->getMessage('new Message');

->save(function($response){

    $response->first();
});

->save(function($response){

    $response->get();
});

->save(function($response){

    $response->form();
});

->save(function($response){

    $userAvatar;

    $response->unlink("public/images/{$userAvatar}", "avatar.svg");

    <!-- the above will only unlink when value is not avatar.svg -->
});

$file = File::name('avatar')
        ->width(700, false);

dd(
    $file
);

File::name('banner')
    ->folder('upload/banner')
    ->validate(function($response){

        // perform any other needed task in here
        echo $response->getMessage();
        return;
    });

File::name('banner')
    ->folder('upload/banner')
    ->save(function($response){

        // perform any other needed task in here
    });

$file = File::name('banner')
            ->folder('upload/banner')
            ->save();

dd(
    $file->get(),
    $file->first(),
);

File::name()
    ->folder('upload/banner')
    ->save(function($response){

        // perform resize
        // width, height
        $response->resize(400, 400);
    });

File::name('avatar')
    ->folder('upload/banner')
    ->save(function($response){

        // perform watermark
        $response->watermark('watermark.png', 'center', 50);
    });

File::name('avatar')
    ->folder('upload/banner')
    ->save(function($response){

        // perform compressor
        $response->compress();

        // you can perform method chaining as well
        $response->resize(200, 450)
                    ->watermark('watermark.png', 'center')
                    ->compress();
        
    });

File::imageSize('name_of_uploaded_file')

[
  ["height"]    => int(4209)
  ["width"]     => int(3368)
]