开发者

1GB file upload using php

I am trying to upload a file of 1GB size using php script and it works per开发者_如何学编程fectly if file size is less than 20MB, but when I increase the file size than after pressing upload button on website, it uploads the file (I guess as it takes few minutes) and after that, instead to execute upload.php, my firefox asks me to download upload.php, so I guess, file is being uploaded but my php script fails to execute.

Also after searching in google I found following settings for php.ini which I made and my php_info() function shows me that settings have been changed..

/*php.ini start*/

memory_limit = 512M

post_max_size = 15000M

file_uploads = On

upload_max_filesize = 15000M

max_input_time = 20000

max_execution_time = 20000

session.gc_maxlifetime = 20000

/*php.ini end*/


The limit on file size uploads is limited by a LOT more than just PHP. PHP has its limits, Apache has its limits, many web services have their own limits, and then you have the limit on the /tmp directory size which could be set by user permissions on a shared host. Not to mention just running out of hard drive space!

Your php.ini looks good, but as was already suggested- check the LimitRequestBody in Apache and make sure your web service allows this.

One common solution when you need to upload very large files is to use Flash or Java on the client-side since these have access to the client's actual file system. The Flash/Java can then break the file into small pieces which are sent one at a time and re-assembled on the server side. This has multiple benefits. First, you can resume broken downloads. Second, you don't have to worry about any scripts timing out. Third, it bypasses any possible file system limits that may be in play from PHP, Apache, web services, or other sources.


post_max_size = 15000M should be higher than upload_max_filesize = 15000M. It can be either post_max_size = 15001M. I've increased it to 1 more.


Check that your web server also allows such large uploads. On Apache the setting is LimitRequestBody. This limit is be applied long before PHP ever enters the picture and cannot be changed/overriden from within PHP.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜