Tuskony Posted April 17, 2009 Share Posted April 17, 2009 Hey guys, I have a form where people can upload up to 5 images. I have it down so you can only upload images etc. But the issue I am having is that if a user uploads a file that's too big, or of the wrong type (IE Not a picture) it is actually uploaded to the file server THEN determined it's invalid. Is there anyway I can get the browser to limit what size of files will even be attempted to get uploaded? I hope this makes sense! Thanks Quote Link to comment Share on other sites More sharing options...
btherl Posted April 17, 2009 Share Posted April 17, 2009 You can never control what the browser does. But php has a directive that will refuse any file larger than a particular size. You can read about it here: http://www.php.net/manual/en/features.file-upload.post-method.php If you use that, the upload will be rejected before your script deals with it. There is an advisory method you can use to request the browser doesn't upload anything larger than a certain size, which is also mentioned on that page. But you can't control if that is followed or not. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 17, 2009 Share Posted April 17, 2009 Also, don't rely too heavily on the $_POST['file']['type'] reported back as I believe this is set by the browser. I was playing with a routine last night and noticed 3 type variations for JPEG files. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.