can not upload larger files - php

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

Related

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.

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.

PHP upload file greater then 2gb [duplicate]

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.

1GB file upload using php

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

Settings for uploading large files (video/mp4)?

Background: I'm planning on using the JW FLV Media Player for streaming some videos:
http://www.longtailvideo.com/players/jw-flv-player/
Question: What settings, both PHP globals and php.ini, would I need to change in order to handle the uploading of large video files?
Sub-question: Is there anyway, through maybe the .htaccess file, that I could have the settings only apply to a single domain? I host several of my websites on the same server, and let's say if I changed the execution timeout to a few minutes for videos I wouldn't someone else on one of my other sites to have to wait through that kind of timeout for a regular upload if an error should occur.
In .htaccess this will let you upload a 20MB file, and increase time for the script to 200 seconds. Most shared hosting won't let you do this though, and will keep a global limit.
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

Categories