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?










share|improve this question




















  • 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















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?










share|improve this question




















  • 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













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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












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)]





share|improve this answer





















  • 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




















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!






share|improve this answer





















  • Still allows me to upload huge images, must be something else
    – Mike
    Nov 8 at 10:49











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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
































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)]





share|improve this answer





















  • 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

















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)]





share|improve this answer





















  • 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















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)]





share|improve this answer












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)]






share|improve this answer












share|improve this answer



share|improve this answer










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




















  • 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 sizedd(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 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






@mike have you tried debugging what I've said above this comment?
– nakov
Nov 8 at 13:25














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!






share|improve this answer





















  • Still allows me to upload huge images, must be something else
    – Mike
    Nov 8 at 10:49















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!






share|improve this answer





















  • Still allows me to upload huge images, must be something else
    – Mike
    Nov 8 at 10:49













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!






share|improve this answer












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!







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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




















































































Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff