1

I have a website where the admin has to upload HD quality movies. The size of movies are almost 2GB+

Will PHP or apache support a file upload of 2GB or greater?

What is the best way to do this? Should I use ajax upload, swf upload(uploadify), or normal form submit upload?

I am using PHP 5.4

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Niraj Chauhan
  • 7,677
  • 12
  • 46
  • 78
  • 5
    Are you sure a browser-based upload is the right way to go here? Uploading 2GB in a browser on a normal connection sounds *insane*. Especially considering you have to restart the entire upload if the connection breaks up for a moment. Have you considered alternatives like FTP? – Pekka Mar 12 '13 at 12:55
  • For *sending* large files trough Apache https://tn123.org/mod_xsendfile/ is very useful... – powtac Mar 12 '13 at 12:57
  • 1
    And your servers disk filesystem needs to support files larger than 2GB – Mark Baker Mar 12 '13 at 12:57
  • Just found http://rightload.org/ – powtac Mar 12 '13 at 13:00
  • Have you went through the previous threads about the subject? http://stackoverflow.com/questions/11590395/php-uploading-large-files http://stackoverflow.com/questions/864570/very-large-uploads-with-php – eis Mar 12 '13 at 13:01
  • @Pekka웃 I am providing an admin tool to the client, he is not going to have access to FTP. Can I give any online control panel tool or something similar to that? – Niraj Chauhan Mar 12 '13 at 13:15
  • @powtac yay for rightload, works great... ntechi, there may be Java applets that allow for more stable uploads inside the browser, but something like FTP is usually really the way to go here. – Pekka Mar 12 '13 at 13:16
  • @Pekka웃 I saw you live in Tübingen... I live in Heidelberg... – powtac Mar 12 '13 at 13:19
  • 1
    @powtac oh, really? Nice! – Pekka Mar 12 '13 at 13:26

3 Answers3

1

Two PHP configuration options control the maximum upload size: upload_max_filesize and post_max_size. Both can be set to, say, “10M” for 10 megabyte file sizes.

However, you also need to consider the time it takes to complete an upload. PHP scripts normally time-out after 30 seconds, but a 10MB file would take at least 3 minutes to upload on a healthy broadband connection (remember that upload speeds are typically five times slower than download speeds). In addition, manipulating or saving an uploaded image may also cause script time-outs. We therefore need to set PHP’s max_input_time and max_execution_time to something like 300 (5 minutes specified in seconds).

These options can be set in your server’s php.ini configuration file so that they apply to all your applications. Alternatively, if you’re using Apache, you can configure the settings in your application’s .htaccess file:

php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_input_time 300
php_value max_execution_time 300

Finally, you can define the constraints within your PHP application:

ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);

PHP also provides a set_time_limit() function so you don’t need to set max_execution_time directly.

Setting the options in your PHP code is possibly more practical, since you can extend the execution time and increase the file size when your application is expecting a large upload. Other forms would revert to the default 30-second time-out and 2MB limit.

Techie
  • 44,706
  • 42
  • 157
  • 243
0

You'll likely need to increae the maximum file upload size in Apache's conf, as well as the post_max_size and upload_max_size directives in your php.ini file.

0

With files >=2GB you might reach some browsers limits.
Additionally, uploading 2GB might take some time (might exceed the timeout of the webserver).
If your connection breaks, you have to re-upload the whole file again.

mfo
  • 152
  • 4
  • The server is likely fine, given that he doesn't have max keepalives set to something restrictive. –  Mar 12 '13 at 13:06