Validation on images if passing despite clear failures, why?
up vote
3
down vote
favorite
I am using Laravel 5.7. I have a form with a file upload on it called logo
. My form has the correct enctype
(enctype="multipart/form-data"
).
I have the following rules against the logo
field:
['required', 'image', 'dimensions:max_width=200,max_height=200']
If I try to upload something that isn't an image it fails, which is correct.
However, if I try to upload a 3000x3000px jpg this goes through without issue and the file is uploaded. It's as though my dimensions
rule is being ignored.
Am I missing something?
php laravel file-upload
add a comment |
up vote
3
down vote
favorite
I am using Laravel 5.7. I have a form with a file upload on it called logo
. My form has the correct enctype
(enctype="multipart/form-data"
).
I have the following rules against the logo
field:
['required', 'image', 'dimensions:max_width=200,max_height=200']
If I try to upload something that isn't an image it fails, which is correct.
However, if I try to upload a 3000x3000px jpg this goes through without issue and the file is uploaded. It's as though my dimensions
rule is being ignored.
Am I missing something?
php laravel file-upload
1
do u use in form multipart data?
– Adam Kozlowski
Nov 8 at 10:42
Yes,enctype="multipart/form-data"
. My file is uploaded, so that isn't the issue anyway, it's that I'm able to upload images far too large and validation is ignored.
– Mike
Nov 8 at 10:44
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am using Laravel 5.7. I have a form with a file upload on it called logo
. My form has the correct enctype
(enctype="multipart/form-data"
).
I have the following rules against the logo
field:
['required', 'image', 'dimensions:max_width=200,max_height=200']
If I try to upload something that isn't an image it fails, which is correct.
However, if I try to upload a 3000x3000px jpg this goes through without issue and the file is uploaded. It's as though my dimensions
rule is being ignored.
Am I missing something?
php laravel file-upload
I am using Laravel 5.7. I have a form with a file upload on it called logo
. My form has the correct enctype
(enctype="multipart/form-data"
).
I have the following rules against the logo
field:
['required', 'image', 'dimensions:max_width=200,max_height=200']
If I try to upload something that isn't an image it fails, which is correct.
However, if I try to upload a 3000x3000px jpg this goes through without issue and the file is uploaded. It's as though my dimensions
rule is being ignored.
Am I missing something?
php laravel file-upload
php laravel file-upload
edited Nov 8 at 10:45
asked Nov 8 at 10:41
Mike
4,95252566
4,95252566
1
do u use in form multipart data?
– Adam Kozlowski
Nov 8 at 10:42
Yes,enctype="multipart/form-data"
. My file is uploaded, so that isn't the issue anyway, it's that I'm able to upload images far too large and validation is ignored.
– Mike
Nov 8 at 10:44
add a comment |
1
do u use in form multipart data?
– Adam Kozlowski
Nov 8 at 10:42
Yes,enctype="multipart/form-data"
. My file is uploaded, so that isn't the issue anyway, it's that I'm able to upload images far too large and validation is ignored.
– Mike
Nov 8 at 10:44
1
1
do u use in form multipart data?
– Adam Kozlowski
Nov 8 at 10:42
do u use in form multipart data?
– Adam Kozlowski
Nov 8 at 10:42
Yes,
enctype="multipart/form-data"
. My file is uploaded, so that isn't the issue anyway, it's that I'm able to upload images far too large and validation is ignored.– Mike
Nov 8 at 10:44
Yes,
enctype="multipart/form-data"
. My file is uploaded, so that isn't the issue anyway, it's that I'm able to upload images far too large and validation is ignored.– Mike
Nov 8 at 10:44
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
I don't see anything wrong with your rule, it is as documented, but just in case something's wrong with the parser, have you tried using:
'image' => ['required', 'image', Rule::dimensions()->maxWidth(200)->maxHeight(200)]
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the sizedd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.
– nakov
Nov 8 at 11:22
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
add a comment |
up vote
0
down vote
Maybe try to use another format of validation like that:
$this->validate($request, [
'image'=> 'required|image|dimensions:min_width=200,min_height=200',
]);
Good luck!
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I don't see anything wrong with your rule, it is as documented, but just in case something's wrong with the parser, have you tried using:
'image' => ['required', 'image', Rule::dimensions()->maxWidth(200)->maxHeight(200)]
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the sizedd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.
– nakov
Nov 8 at 11:22
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
add a comment |
up vote
0
down vote
I don't see anything wrong with your rule, it is as documented, but just in case something's wrong with the parser, have you tried using:
'image' => ['required', 'image', Rule::dimensions()->maxWidth(200)->maxHeight(200)]
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the sizedd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.
– nakov
Nov 8 at 11:22
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
add a comment |
up vote
0
down vote
up vote
0
down vote
I don't see anything wrong with your rule, it is as documented, but just in case something's wrong with the parser, have you tried using:
'image' => ['required', 'image', Rule::dimensions()->maxWidth(200)->maxHeight(200)]
I don't see anything wrong with your rule, it is as documented, but just in case something's wrong with the parser, have you tried using:
'image' => ['required', 'image', Rule::dimensions()->maxWidth(200)->maxHeight(200)]
answered Nov 8 at 10:47
nakov
1,23888
1,23888
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the sizedd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.
– nakov
Nov 8 at 11:22
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
add a comment |
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the sizedd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.
– nakov
Nov 8 at 11:22
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
Still allows me to upload huge images unfortunately
– Mike
Nov 8 at 10:48
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
@Mike which version of Laravel are you using, I just tried your rules on my project and I get the correct error which is: The picture has invalid image dimensions.
– nakov
Nov 8 at 11:01
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
Laravel Framework 5.7.12
– Mike
Nov 8 at 11:08
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the size
dd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.– nakov
Nov 8 at 11:22
I use the same, all seems fine in my project. Try another image or check if PHP reads the resolution right by printing out the size
dd(getimagesize(request()->file('image')));
the first two items of the array are the resolution.– nakov
Nov 8 at 11:22
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25
add a comment |
up vote
0
down vote
Maybe try to use another format of validation like that:
$this->validate($request, [
'image'=> 'required|image|dimensions:min_width=200,min_height=200',
]);
Good luck!
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
add a comment |
up vote
0
down vote
Maybe try to use another format of validation like that:
$this->validate($request, [
'image'=> 'required|image|dimensions:min_width=200,min_height=200',
]);
Good luck!
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
add a comment |
up vote
0
down vote
up vote
0
down vote
Maybe try to use another format of validation like that:
$this->validate($request, [
'image'=> 'required|image|dimensions:min_width=200,min_height=200',
]);
Good luck!
Maybe try to use another format of validation like that:
$this->validate($request, [
'image'=> 'required|image|dimensions:min_width=200,min_height=200',
]);
Good luck!
answered Nov 8 at 10:48
Adam Kozlowski
1,647617
1,647617
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
add a comment |
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
Still allows me to upload huge images, must be something else
– Mike
Nov 8 at 10:49
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206035%2fvalidation-on-images-if-passing-despite-clear-failures-why%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
do u use in form multipart data?
– Adam Kozlowski
Nov 8 at 10:42
Yes,
enctype="multipart/form-data"
. My file is uploaded, so that isn't the issue anyway, it's that I'm able to upload images far too large and validation is ignored.– Mike
Nov 8 at 10:44