Why can't I upload large files on my PHP website? - php

I am having a problem with uploading files bigger than a certain size (around 150MB/200MB) to my server.
Because I do not have this problem on my local server, I suspect it has something to do with settings on the shared server which I rent that runs Apache.
The error that I am getting is HTML error 413 Request Entity Too Large
Ofcourse I have done some research and found that the php settings on the server are set correctly as follows:
max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 2048M
post_max_size = 2048M
memory_limit = 4096M
max_input_vars = 2000
Furthermore, because the server runs on Apache, I made sure to also add
LimitRequestBody 2147483647 and
SSLRenegBufferSize 2147483647 to the .htaccess file which translate to 2GB for both settings.
For the code I just use the PHP move_uploaded_file($_FILES["video"]["tmp_name"], "../videos/". $newVideoName)) method which, one again, does work with smaller files.
Is anyone familiar with this problem or have any other solutions on how to fix this problem? I did talk the my host and they have said that there aren't any restriction on uploaded filesizes other than the PHP settings which I have changed.
Thanks upfront!

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.

How to change php.ini memory_limit per folder when php is set up on FASTCGI API

Hi I have a site that requires extra memory allocation for an image upload system. On the development server changing the memory_limit is not an issue but on the live server php has been set up using FASTCGI as the API and not Apache. This now causes me a problem as I can not change the setting using any of the following. Has anyone come across this before and can offer a solution.
Methods already tried:
ini_set('memory_limit', '250M') in the script file
.htaccess php_value memory_limit 250M
php.ini added to the directory holding the script file memory_limit = 250M
php.ini copy of whole file with memory limit changed
Many thanks

Increase File Upload Size Wordpress / IIS 7

I'm trying to increase the file upload size in a Wordpress blog to allow an admin to post his e-books and large PDF files. The site is hosted on GoDaddy / IIS 7. I have tried the following with no luck:
web.config:
<configuration><system.webServer><security><requestFiltering><requestLimits maxAllowedContentLength="10000000"/></requestFiltering></security></system.webServer></configuration>
php.ini in root of site:
upload_max_filesize = 64M
Any advice is greatly appreciated.
Thanks,
Shawn
Solution found here:
Step 1:
First, you need to edit your server’s PHP.ini file. This is found in
your PHP installation directory, e.g. c:\program files\php\php.ini and
set the following values:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
This allows PHP to handle files up to 64MB and allows PHP scripts to
run up to 5 minutes before timing out.
Step 2:
Lastly, IIS 7 has a default file upload limit of 30MB. Anything larger
than that will cause IIS to return a very unhelpful 404 status. You
can read more about it at
http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits
To override this, you need to change the web.config settings for
(each) site. (The only catch here is that the limits are expected to
be in bytes instead of kilobytes.) The following is some copypasta
from the MSDN docs:
Don’t forget to recycle your application pool so IIS picks up your
PHP.ini changes.
And that’s it!
http://refactored.tumblr.com/post/4609761388/wordpress-iis7-uploads
you will have to modify the active php.ini which you can get get from a phpinfo() and change both post_max_size and upload_max_filesize accordingly. Once done, restart iis
I had to adapt the first solution above, because I am using Windows Share HostGator site. I had a file in httpdocs called: .user.ini, which I added:
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 600
max_input_time = 600
Because I needed it bigger. I also added:
<security><requestFiltering><requestLimits maxAllowedContentLength="268435456"/>
</requestFiltering></security>
So this allowed me upload larger files. I wanted to be able to upload large videos or mp3 files.

Max File Size php server

I am using wamp as my test server and when trying to upload videos I am getting an error code 1 which is an error saying that my max file size is to small. I changed my php.ini settings to
; Maximum allowed size for uploaded files.
upload_max_filesize = 700000000000000000M
and i changed my htacess file to say this ..
RewriteEngine On
php_value post_max_size 1000000000000000000M
php_value upload_max_filesize 1000000000000000000M
php_value max_execution_time 60000000000000
So there is plenty of room I don't understand why i still get this error .. Thanks in advance for the help.
Were you sure that you restarted Apache after you edited the php.ini file?
Apache loads the php.ini on start so if you made changes without restarting Apache the changes will not take effect.

PHP SOAP Service - Uploading file larger than 15MB fails

Is there anything that would be preventing a PHP SOAP Service from uploading a file larger than about 15MB? Smaller files work great, but larger ones fail without any noticeable errors.
Settings that I might need to change? Nothing in the apache logs.
Make sure you've set upload_max_filesize in your php.ini to a value higher than 15MB. For example:
upload_max_filesize = 20M
post_max_size = 20M

Categories