I am Trying to validate the dimension of an image.. if either width or height is greater or equals to 1080px i need to pass the validation.. but my code is not working properly.. can someone point out where is the mistake.. Thanks in advanced :)
Yaa guys i tried max_width and min_width option... But not working as axpected... I want to pass the validation.. If one of them (width, height) is 1080px. Thanks for the replies.
Thanks for the code...
i tried it but got this error - getimagesize(file): failed to open stream: No such file or directory
further i change the code to
I change the code as below... but now it's not give any error.. just passed the validation even for the wrong dimension image.
function ($attribute, $value, $fail) use ($request){
list($width,$height) = getimagesize($request->file('file'));
if($width > 1080 && $height > 1080) {
$fail($attribute . ' must be at least 1080 in any direction');
}
}
b) does not match your request because you said that the image had to be at least 1080 in one direction only. Your current code checks that the image is at least 1080 in both directions.
For the example you have now, you could have just used min-height and min-width