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.
Related
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
I am facing a read timeout problem from couple of days.
There is a facility to upload users in my application (Xls,xlsx are allowed extensions). This is completely admin panel.
I am using PHPExcel for reading the data from the sheet and inserting each row details into database on the fly.
Here, there is a possibility to upload large size files. Right now the file I am having is 16MB file which contains nearly 200k records.
I have increased below configurations through htaccess
php_value memory_limit 1024M
php_value max_execution_time 259200
php_value max_input_time 3000
php_value post_max_size 700M
php_value upload_max_filesize 100M
I have placed set_time_limit(0) in the specific controller also.
My problem is read timeout in production environment. It is executing for around 15 mins and returning the below error
The requested URL could not be retrieved
While trying to retrieve the URL: http://example.com/upload/url
The following error was encountered:
Read Timeout
The system returned:
[No Error]
A Timeout occurred while waiting to read data from the network. The network or server may be down or congested. Please retry your request.
Will Keep Alive do something here. It is set to 5 in production and Apache timeout is 300.
I have searched many of the similar errors post in this site but no luck
I am planing to set a cron job, uploading the files only from front end. Hope that will solve this but I also want to know what factor is causing this error.
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.
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.
I have an image upload for a slideshow, and the users are continuously uploading files that are 2MB plus. Files under this size work fine, but files over the size cause what looks like a browser timeout.
Here are my php ini settings:
Max memory allocation: 12M
Max file upload size: 10M
Max HTTP Post size: 10M
Max execution time: 60
Max input parsing time: 120
These settings are in the configuration file itself, and I can change them directly. Changes show up when using phpinfo().
I am running on an apache server and php 4.3.9(client's choice, not mine). The apache server's request limit is set to default, which I believe is somewhere around 2GB?
When I use the firebug network monitor, it does look like I am not receiving a full response from the server, though I am not too experienced at using this tool. Things seem to be timing out at around 43 seconds.
All the help I can find on the net points to the above settings as the culprits, but all of those settings are much higher than this 2MB file and the 43 second time out.
Any suggestions at where I can go from here to solve this issue?
Here are relevant php ini settings from phpinfo(). Let me know if I need to post any more.
file_uploads On On
max_execution_time 60 60
max_input_nesting_level 64 64
max_input_time 120 120
memory_limit 12M 12M
post_max_size 10M 10M
safe_mode Off Off
upload_max_filesize 10M 10M
upload_tmp_dir no value no value
Make sure you have error reporting activated in php.ini: display_errors = On; this might give you a clue about what's going on. Production servers usually (should) have error reporting disabled.
I recently had a similar problem, and increasing the memory_limit setting worked for me. If you read files content into variables, each variable will take about as much memory as the file size, increasing the scripts memory requirements.
Where are those settings? If you're using .htaccess then your Apache configuration might not be allowing you to override those settings.
I'd suggest checking with a phpinfo() call if those settings are indeed being applied or not:
<?php
phpinfo();
?>
If it's a shared host, your host might have set a limit to override yours.
Otherwise, try making the POST limit higher than the file upload size. AFAIK, uploads are POSTED.
If the problem is due to the Host overriding your timeout, you can look for a host that still uses Apache 1: In Apache 1 the local .htaccess overrides the global setting even for the timeout.
Otherwise, there are dozens of Java applett uploaders available for just a few dollars (Google it). They split the file, upload the parts and put the parts back together transparently.
This is a guaranteed fix for timeout, and has the added advantage of letting users pause and resume their upload, see the progress, et all.
(Flash based uploaders don't have this advantage.)