473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to detect if post_max_size triggered?

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_filesize 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:
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.php?processed=1">, and then checking if $_GET['processed'] is set.
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?
Aug 22 '06 #1
2 7062
vssp
268 100+
Please chage php.ini file and set the maximum uploaded file size and restart the server then check the program
Aug 25 '06 #2
Afraid that doesn’t do me any good.
I’ve tried before setting the upload_max_filesize smaller than post_max_size which you would think would cancel the connection and report the upload_max_filesize exceeded error before post_max_size was reached but it seems so long as the file being uploaded is at least the size of post_max_size then post_max_size is triggered and all $_POST information wiped out even if upload_max_filesize lower size threshold was reached way before post_max_size was.
I just want to know when post_max_size has been reached from within my script.
Below is what I get in my php log when I have upload_max_filesize set to 4mb and post_max_size set to 8mb:
PHP Warning: POST Content-Length of 8750362 bytes exceeds the limit of 8388608 bytes
Is their a way of catching this error report from within my php script?
Aug 25 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ken | last post by:
How can I recover from total files uploaded is greater than post_max_size? 8M When total file size uploaded is greater that the post_max_size, sessionid() is lost. Sessionid does not carry...
1
by: MightyMo | last post by:
Is it possible to detect the user's next location? I need to be able to detect if a user is abandoning the site. window.location and window.location.href triggered by onUnload can only tell me...
1
by: Gordon | last post by:
Hi there, I have a VB.NET application which opens a new Excel workbook (and obviously worksheet). The cell values in the worksheet depend on certain formulae, therefore the sheet Calculate event...
0
by: timbobd | last post by:
Using Visual Basic .NET 2003, I have created a combobox with custom code for "autocomplete" functionality and to trigger a DropDown event when the user starts typing. I want to do a database lookup...
1
by: veg_all | last post by:
I dont have access to my php.ini file so I am trying the following which doesn't seem to work: <input type=hidden name=post_max_size value=100000> I know it can be done for file uploads, but...
6
by: Eric Layman | last post by:
Is there a way to detect a held-down button while the mouse is moving? Thanks. Posted Via Usenet.com Premium Usenet Newsgroup Services
0
by: thiruscripts | last post by:
Hi, I need to detect the keyvalue while keypress. ie irrespective to control. For example if i press some characters in textbox the some event to be triggered. In the condition the event should be...
4
by: nrocha | last post by:
Hello, I've been trying to detect when a user closes a page or navigates away from it. This is part of a solution for locking pages (that is, if a user enters a page, no one else can enter it...
1
by: jamesm6162 | last post by:
Hi Suppose for a moment that you do NOT have access to the php.ini file.... Okay, now, I have a form to upload images and it does contain the MAX_FILE_SIZE hidden input field, and it does...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.