I would like to flag when the client attempts to upload a large file (as opposed to one that doesn't exist or an empty one). There are two issues here. The first is that if I set $MAX_FILE_SIZE (or another of the relevant variables) PHP (seemingly) receives the file and then discards it. Is there any way that I have to figure out that PHP got the file and then kicked it out as opposed to a bad (or no) file name being supplied in the first place? In both cases $HTTP_POST_FILES['myfilename']['size'] is 0.
The second and more general situation is that I wish to make this detection before the download happens. After all, once the file has been downloaded, I could always do the size check myself, and do the appropriate actions (i.e. display error for no file, parse the file for allowed sizes, and kick back a special message (like getting credit card info) for large sizes). However, this leaves me open to the prankster who wants to burden my server by uploading 8MB files all day.
So my question is (and perhaps it should go to an Apache group):
How can I trap for an upload exceeding a specified size before the upload happens while allowing smaller uploads (and empties) to go through?
Thanks,
Csaba Gabor