PHP code example of jdavidbakr / upload-aws

1. Go to this page and download the library: Download jdavidbakr/upload-aws 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/ */

    

jdavidbakr / upload-aws example snippets


// Instantiate with the $_FILE array.
// Uses config('aws.bucket') or you can pass the bucket as the second argument of the constructor.
$upload = new \jdavidbakr\UploadAWS($_FILE['form_name']);

// Retrieve the location of the uploaded file and store it somewhere
$location = $upload->get_location();

// Instantiate with the remote file path
$upload = new \jdavidbakr\UploadAWS($location);

// Get a temporary signed URL
$url = $upload->get_url();
// Resize the image
$upload->resize_image(640,480);
// Resize the image so that it fits in the max size
$upload->get_max_size(1000,1000);
// Scale image, applies pillarbox or letterbox to retain the aspect ratio
$upload->scale_image(640,480);
// Crop the image to this size, will retain the current image center
$upolad->crop_image(640,480);
// Crop the image with full control over what part of the image to keep
$upload->crop($top, $left, $width, $height);
// Copy the image into a new file location
$upload->copy();
// Delete the remote file
$upload->delete();
// Get the actual size of the file
$upload->get_file_size();