Hi all, I’m creating a site that allows file uploads to registered users. I’ve got a system in place where if the user uploads a overly large file that it would automatically warn them off the offence and keep a record of it, if it was way over the file size limit I allow for (naturally the file is destroyed as well). If they continued to try to upload large files they would receive a temp ban. This relies on the system being able to determine how big the file was as I cannot simply punish a legit user who simply goes a little over the file size (that just wouldn’t be very nice :) ). Now if the file they uploaded was greater than upload_max_file size the file size information would be 0 but I could still determine that this limit was reached thanks to the $_FILES['file’]['error'] array and take appropriate actions.
Unfortunately I discovered recently that if post_max_size was triggered then php just totally wipes out both $_POST and $_FILE globals and seems to pass absolutely no errors back to the script making it totally impossible to determine if someone keeps trying to upload massive files eating into my bandwidth.
Heres what I found from the php manual:
Their suggested method of tracking the event is not useful to me as a legit user could get punished if they somehow accidentally put this query string into their URL.
I noticed though that if post_max_size is exceeded then it gets recorded in the php.log, so php must be outputting something.
Sorry if my post has been a bit long winded but any suggestions on how I can detect if post_max_size was triggered?
Unfortunately I discovered recently that if post_max_size was triggered then php just totally wipes out both $_POST and $_FILE globals and seems to pass absolutely no errors back to the script making it totally impossible to determine if someone keeps trying to upload massive files eating into my bandwidth.
Heres what I found from the php manual:
If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.ph p?processed=1"> , and then checking if $_GET['processed'] is set.
I noticed though that if post_max_size is exceeded then it gets recorded in the php.log, so php must be outputting something.
Sorry if my post has been a bit long winded but any suggestions on how I can detect if post_max_size was triggered?
Comment