I have been trying image uploading in Laravel 5 (upload generated through laravelcollective/forms, and processed using Intervention Image library). What I wanna do is when user uploads any photo, I want to set the extension based on its mimetype. There should be some basic check to protect against spurious data injection.
$file_profile_image->getClientMimeType();
To do that, should I simply be mapping like so ?
['image/jpeg' => 'jpg', 'image/gif'=> 'gif']
This is how I would do it:
The
get_image_details($path)
function can be defined as follows:I would use the Intervention package to check if you're loading a valid image and get the mime from there.
Something like this: