6
votes

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*/

3
actually i am making a website which can upload files and than user can share file link with other users...Sanniv
As a side note: If you're uploading a 1GB file, you should use a Flash Uploader (what Gmail/Youtube/etc use for advanced uploading) because it allows for easy drag and drop, but most importantly, a visually appealing progress bar.Kranu
@Kranu, your idea is pretty good, it will definitely increase the usability.. I'll do it once I find my problem's solution...Sanniv

3 Answers

7
votes

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.

1
votes

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.

1
votes

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.