473,569 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect if post_max_size triggered?

2 New Member
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:
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.
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 7078
vssp
268 Contributor
Please chage php.ini file and set the maximum uploaded file size and restart the server then check the program
Aug 25 '06 #2
MagicMyth
2 New Member
Afraid that doesn’t do me any good.
I’ve tried before setting the upload_max_file size smaller than post_max_size which you would think would cancel the connection and report the upload_max_file size 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_file size 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_file size 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
6187
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 through to the called page. This happens wether I upload 2 x 4.7M files or 6 x 1.6M files. Is there a way around this?
1
1861
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 the current location, and I can't tell where the next location is. If you know of a way to do this, please let me know!
1
7257
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 is triggered whenever a calculation occurs. My problem is that I can't find a way within this event to find out exactly which cell has changed....
0
1067
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 after the user has selected a new value. However, since this can query hundreds of rows, I don't want to do a lookup every time the user types a...
1
4318
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 can it be done for posting data?
6
3543
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
896
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 general not related with specified control. If any keypress detect the control where the key pressed Thank u
4
7902
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 while he doesn't leave). I'm using the window.onunload event to trigger the unlocking of a page, but I don't want the page to be unlocked when a...
1
2390
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 appear before the file upload input field. It sets the max upload size to roughly 3MB The current value of the php directive post_max_size is only...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.