Skip to content

Instantly share code, notes, and snippets.

@keithweaver
Last active May 18, 2023 16:44
Show Gist options
  • Save keithweaver/08c1ab13b0cc47d0b8528f4bc318b49a to your computer and use it in GitHub Desktop.
Save keithweaver/08c1ab13b0cc47d0b8528f4bc318b49a to your computer and use it in GitHub Desktop.
Upload image using link to AWS S3 with PHP
@pedrozancope
Copy link

Hey keithweaver, on line 51, how would you do the randon string for the filename?

@vikupilot
Copy link

After 60 second the server timeout and file can't upload into the Amazon S3 ,because the size of picture is 15 mb.how can I upload this .

@marcoavazquez
Copy link

Thank you very much!!

@bhaveshcr
Copy link

Thanks.

@Mhmdkrissaty
Copy link

Good one thanks.

@devope
Copy link

devope commented Dec 15, 2020

thanks a lot

@1000heads-luke
Copy link

Hey keithweaver, on line 51, how would you do the randon string for the filename?

@pedrozancope, I typically name a filename starting with the Date (& possibly time), then a quasi-unique hash, then a filename.

So:

// Presuming the original filename is held in $filename_original.

$filename_s3 = date( 'Ymd_his' ).'-'.md5( time() . $filename_original ).'-'.$filename_original;

The likelihood of having a collision uploaded at the exact same second, with the exact same filename is practially zero. The benefit of this method is also that the original extension of the filename is retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment