PHP upload file greater then 2gb [duplicate] - php

This question already has answers here:
Uploading a file larger than 2GB using PHP
(6 answers)
Closed 9 years ago.
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

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.

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.

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.

Related

Upload big file using PHP

I'm trying to upload big files using PHP and it's not working and the size is around 855 ko. I've already tried uploading smaller files and its worked so i'm sure that my problem that causing the error.
I've already tried most of the solution in SO and google but in vain. Some said that i should try to configure my php.ini and i did but without success.
I'm using lighttpd on an embedded system.
My php.ini configuration :
max_execution_time = 300; Maximum execution time of each script, in seconds
max_input_time = 25200; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 40M ; Maximum amount of memory a script may consume (128MB)
file_uploads = On
upload_tmp_dir =/home/imagesdcard/www/
upload_max_filesize = 10M
max_file_uploads=2
I had tried many solutions that suggesting it was caused by certains configurations in php.ini and i had changed it but without success.So, i wanna ask how can i upload big files using php?
Thank you in advance for all advice and help and have a great day.
By configuration, PHP only allows to upload files up to a certain size. There are lots of articles around the web that explain how to modify this limit. Below are a few of them:
PHP Increase Upload File Size Limit
How do I increase the PHP upload limits?
For instance, you can edit your php.ini file and set:
memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M
You will then need to restart apache.

Connection reset error on multiple file upload

I have problem in multiple file upload in php. I have set php.ini setting in .htaccess file
php upload_max_filesize 1024M
php post_max_size 1024M
php max_execution_time 120
php max_input_time 120
php max_file_uploads 40
So when I upload images approx 40M size then server respond with status failed or connection reset instead of it upload images within 1 min time .If I upload little less than 40M then its working fine.Is there any other setting I have to do. How I can fix this issue.
Most likely you're running against the clock or have conflicting settings, but it's hard to tell with the amount of information you provided.
Even though you set up your PHP instance to accept uploads of up to 1024M (are you sure you need this, by the way?) there's a lot more you need to consider:
php max_execution_time 120
php max_input_time 120
The above means that whatever happens, your PHP instances will be stopped after 120 seconds. It may be that you are able to upload almost 40M in under 120 seconds.
Now, even if you had a connection speed that allows to upload more than 40M in less than 120 seconds, there's more settings thay may be conflicting, as the above ones only apply to the PHP process.
Check your Apache settings (I assume you use Apache given the tag on your question) and look for Apache's directives regarding execution times and upload limits. Even if PHP was configured to allow 1 Terabyte per file and 24 hours per process, if Apache has more restrictive limits, Apache will be constraining your upload sizes and running times.

can not upload larger files

hello all i am having a dedicated server and even after increasing the max_upload size and memory limit i can not upload videos of larger size please check the image
i have a dedicated server from bluehost and the site is like video hosting site so i need to allow almost all file sizes but till now i have alloed max_file size arround 900 mbs but i can not upload files more than 10-20 mb please let me know if there is anything that i should do on my behalf.
By default, PHP permits a maximum file upload of 2MB. You can ask users to resize their images before uploading but let’s face it: they won’t. Fortunately, we can increase the limit when necessary.
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

max_execution_time affecting uploads?

Can max_execution_time (which I left to the default value of 30) in php.ini affect uploads? I set upload_max_filesize and post_max_size to 20M and client_max_body_size (in nginx) also, but some users keep telling me they have problems uploading files larger than (say) 1M (I/O upload error) whereas they can upload without any issues 400KB files.
Maybe with slow connections the flash(?) script exceeds the 30s limit and the upload isn't finished..?
No max_execution_time does not affect uploads, however max_input_time does.
See http://nl3.php.net/manual/en/features.file-upload.common-pitfalls.php
No. From the documentation:
The maximum execution time is not affected by system calls, stream operations etc.

upload large files [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Large .PDF Files Not Uploading To MySQL Database as Medium BLOB Via PHP, Files under 2MB Work Fine
Running Unix and php5.
I have an upload form that allows people to upload any file format at any size. As of now when you try to upload it fails most of the time when I try to upload a couple mb file. However if I upload a small text file it is fine. Also I have read about issues of timing out with large files. Is there something I can do server side or preferably in my php code to enable someone to upload really large files without it timing out? Is the browser limit 500MB?
There is a server limit in php.ini here
change the size to allow larger files, default limit is 2 MB.
There isn't a browser limit afaik, but in general uploading large files from the browser just ends up being trouble. Perhaps a an anonymous FTP (with hidden list) would work?
#keith you can try out uploadify plugin you can download from here
http://www.uploadify.com/ and then you can set php_values like this
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 1000
php_value max_input_time 1000
in .htaccess

Categories