views:

102

answers:

2

Hi,

I am trying to upload a file of 1GB size using php script and it works perfectly 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*/

Please help me out to resolve this problem.....

Thanks..

+1  A: 

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.

Marc B
+3  A: 

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.

steven_desu
Steven, now I am able to upload 100MB file by adding .htaccess file in my website folder it is like below: <IfModule mod_rewrite.c> RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteCond %{REQUEST_URI} myuploadfolderRewriteRule ^(.*)$ http://www.mywebsite.com/index.html [R,L]</IfModule><IfModule mod_php5.c>php_value max_input_time 0</IfModule> I think your suggestion can help me to upload around 1GB file, but when i try to add LimitRequestBody in this .htaccess file, I get internal server error 500, so can you tell me where i should make change and how for LimitRequestBody..
Sanniv
http://httpd.apache.org/docs/current/mod/core.html#limitrequestbody Make sure that you specify in bytes `LimitRequestBody 1073741824` and also make sure your web server allows this command. Some webservers have external checks in place to make sure too much data isn't being sent in a single request. This saves them bandwidth and ultimately saves them money. If it's allows, you should be able to place it at the very end of your .htaccess file. I recommend putting it in the same folder as your upload script to prevent DoS attacks on your webroot.
steven_desu