Question

I"m using InkFilePicker to allow my website users to upload Images through my site. Ink uploads it to my Amazon S3 bucket (bless them!) and returns a URL after the upload is complete. Problem is, I want those images stored on my server instead!

OK, so the URL I get back from Ink looks like this:

https://www.filepicker.io/api/file/JNJB5DkqR8C4OAbzXh8z

Yup, no file extension. Pfft .. I'll need to figure out the original file type for this image so that I can assign it a file extension when I save it to my server.

But HOW? It's displayed properly in my browser - so there must be a way!

Était-ce utile?

La solution

You can use PHP getimagesize() function

Like this:

$img = getimagesize('https://www.filepicker.io/api/file/JNJB5DkqR8C4OAbzXh8z');

echo $img['mime']; // image/png

If you want to just extract the extension without MIME Type. You can use image_type_to_extension

echo image_type_to_extension($img[2]); // .png
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top