How to verify that an image is really an "Image" or a PDF is really a "PDF document" during the upload ?. i observed a hack attempt to upload some files with jpg extension which has a picture preview but when i tried to open this file in an editor i saw php codes !! .
My concern is about :
how can i verify that a file is a real file ?
Im using laravel framework, I tested with image mimes validation as shown below:
$inputs = array('image'=>$request->file('file'));
$rules = array(
'image' => 'mimes:jpeg,jpg,png,gif|required|max:10000'
);
$validator = Validator::make($inputs, $rules);
if ($validator->fails()){
die('validation failed');
}else{
die('validation Passed');
}
But this validation always pass if i try to upload the invalid jpeg file with some php injected codes!!