开发者

Need workaround for AJAX uploader requiring massive PHP ini memory limit, seg faults when exceeding!

We have recently replaced our flash-based uploader with this ajax one:

http://valums.com/ajax-upload/

Unfortunately, this uses the POST mechanism to transfer data to the server, which means that if I have a 50MB upload limit, I need to add at least 50MB to my PHP ini, as the data is added into the $_POST array.

Unfortunately, this means that all pages now have this huge added limit, which is not acceptable. I cannot even set the limit for the page on the fly, since using the ini_set would occur AFTER the $_POST processing had occurred. Can anyone think of an alternate solution?

In addition, anything exceedin开发者_StackOverflowg the max limit causes a PHP seg fault / Fatal Error! Any ideas?


You can do something like this in Apache in the .conf file for your site's configuration:

<Location /upload.php>
   php_value memory_limit 60M
</Location>

That makes the higher memory limit apply only to scripts invoked /upload.php in the URL. You can do similar overrides with <Files>, <FilesMatch>, <Directory>, etc...

The override has to be done at this level, since as you've found out, by the time ini_set would get executed, the script's already been killed.


The memory limit will not preallocate the 50Mb, it's a hard limit to how much it can use. If previously no script is failing, it's quite probable that you won't notice the increased memory limit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜