Laravel basically have following below functions for input type file.
// Determine if a file was uploaded
Input::hasFile('filename');
// Access file properties
Input::file('name')->getRealPath();
Input::file('name')->getClientOriginalName();
Input::file('name')->getClientOriginalExtension();
Input::file('name')->getSize();
Input::file('name')->getMimeType();
If i use getClientOriginalExtension to find correct image extension, getSize to restrict file upload size & getMimeType to check the mimetype of image.
Am i secured ? And can have faith on function that , it will not be exploited by hacker in any way.
Considering a fact, that i will be only uploading image.
Update : Follow below URL for File Uploading Securely with Core PHP :
http://php.w3clan.com/tutorial/47/form-handling-secure-uploading
or Just use file validation in rule as per Laravel
$rule = [ 'name' => 'image' ];
$rules = [ 'file' => 'image' ]getMimeTypeto check for the mime type as far as I'm aware since theimagerule in the validator checks for mime types image/png, image/jpeg, image/gif and others. If you further want to whitelist to for example only jpg and png, you can check for the extension aswell. Although only checking for the extension can let people upload any file they wish if they change the extension. I could upload an executable which is named definitely-not-an-exe-file.png and still be able to upload it.getClientMimeType()andgetClientOriginalExtension()