is before the file input use enctype=“multipart/form-data” for form …
SUCH AS THE EXAMPLE !!!
but why when i upload larger file that MAX_FILE_SIZE php still wait for uploading file and do not stop uploading and give me
UPLOAD_ERR_FORM_SIZE and reject the file …
I MUST WAIT FOR UPLOADING COMPLETE WHHHYYY ??? :sick:
MAX_FILE_SIZE does get checked - at the PHP level, and AFTER the upload has completed. PHP has no way of knowing how big something is before you send all of it.
Think of it this way: I say to you, ‘I’m going to send you some apples.’. Am I going to send you 2? or 200,000,000? You dont know. How can you tell me if you have enough space if you dont know?
Now. It’s possible (though i havent explored the possibility, so i may be wrong) that Javascript might be able to head things off at the pass here. Form-validation, sort of.
Well as far as I know, PHP will never give error before starting to upload. It will always check when the form will be submitted. (May be there are ways if any I dunno any but, more advance users can help it then.)
If you wanna check that before sending information to server, then you need some client side function or script.
While as for PHP goes, You need to define the file size to be accepted and then check that value with
I’ve found that this just REALLY frustrates users. Most of them don’t realize why their upload was rejected. MANY of them confuse image size (5" X 7") with File Size.
Long story short, I basically opened up the floodgates on my sites and allow virtually any size image to be uploaded. I then use an image processing script to size it down to the dimensions the site needs.
Now, that being said, I have full control over the people doing this uploading. So giving them full access such as this is not a compromise for anything other than server space (which is ultra cheap anyways).
Now, if you are doing this for a social network or something where any Joe Schmoe will be able to upload then yes, you may have to restrict. But otherwise, let them post whatever it is they want to post.