homepage Welcome to WebmasterWorld Guest from 54.205.247.203
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
behavior when post_max_size is exceeded
jbrudolf




msg:1263220
 3:11 pm on Jan 28, 2005 (gmt 0)

Greetings fellow PHPers:

I am trying to set an 8MB limit on files that users can upload. In php.ini I have set upload_max_filesize to 8MB and post_max_size to 12MB. If a user uploads a 10MB file, then $_FILES['filename']['error'] equals 1, as expected. However if the user uploads a 13MB file, then PHP writes a warning message to syslog and simply gives up; it doesn't write *anything* to stdout! (I'm using PHP4.3 on WinXP with Apache2). I try to register my own error handler in the upload script but nothing happens; I'm guessing PHP gives up before the script ever gets loaded. And I have not been able to find documentation explaining how to gracefully trap the case where post_max_size is exceeded. (IMHO, setting post_max_size to 120MB is definately *not* graceful, because a 75MB file will still be uploaded, instead of interrupting the transfer after the limit has been exceeded.)

Can anyone point me to documentation, or offer any suggestions how I can get around this problem?

Thanks in advance,

Jim

 

jollymcfats




msg:1263221
 4:41 pm on Jan 28, 2005 (gmt 0)

You could try putting your post limit in Apache's LimitRequestBody directive. The Apache docs say that an error is returned if the POST exceeds this limit, and you can probably trap this with ErrorDocument.

jbrudolf




msg:1263222
 9:48 am on Jan 31, 2005 (gmt 0)

Ideally I should be able to do this in PHP itself. Unfortunately I don't find a description in the PHP doc for how PHP responds when post_max_size is exceeded; it only talks about how to increase the max size.

jollymcfats




msg:1263223
 10:34 am on Jan 31, 2005 (gmt 0)

The "docs" are here [cvs.php.net]. Search for 'post_max'. It doesn't look like there's any way to trap this condition.

corz




msg:1263224
 4:34 pm on Jan 31, 2005 (gmt 0)

you could always try preventing it with a hidden form element..

<input type="hidden" name="MAX_FILE_SIZE" value="10485760">

though some browsers may ignore this.

;o)
(or

jbrudolf




msg:1263225
 10:36 pm on Jan 31, 2005 (gmt 0)

...however the MAX_FILE_SIZE check in the form -- when not ignored by the browser -- will only take place after the entire file has been uploaded... which is exactly what I would like to avoid, in case some wiseguy tries to upload a 100MB file...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved