Issue while uploading files on windows server with php - php

We are facing an issue in file uploading on windows server running php. Bigger files are not uploading to the server. The site is hosted in a windows 2008 server and the webserver is IIS 7.
Sometimes it is possible to upload 22MB files, but sometimes the upload fails for 10 MB file. There is no error messages in the log files.
We have set very higher values in PHP.ini files.
max_execution_time 1800
max_input_time 1800
memory_limit = 5000M
upload_max_filesize = 60M
max_file_uploads = 40
post_max_size = 400
We also tried to increase the IIS upload limit by adding the values in web.conf file. It's also not solved the issue.
maxRequestLength="204800"
requestLengthDiskThreshold="204800"
executionTimeout="3600"
maxAllowedContentLength="204800000"
http://support.myeasyprojects.net/KB/a53/uploading-large-files-times-out.aspx
We are in the middle of a very confusing issue. Can anyone help us out on this?

post_max_size should match upload_max_filesize because files are sent with POST.
Memory limit is very high, do you really need all that memory? 256M should be enough.
My suggested configuration:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M

Need to do the following setting into the php.ini files. which is located into your c:\php
post_max_size (it should be greater than the upload_max_filesize);

Related

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

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!

PHP ERR_CONNECTION_RESET error with FILE UPLOAD more than 8MBs

My server settings are as below:
max_execution_time : 0
max_input_time : -1
memory_limit : 128M
upload_max_filesize : 128M
post_max_size : 128M
still I am getting ERR_CONNECTION_RESET while uploading a file (size > 8MBs). Not even var_dump($_FILES); is working. Any file size below 8MBs is uploading easily. Not sure where I am wrong. Please suggest.
Although all the server configurations are set still I am getting the same issue.
Check your php settings for both of these:
upload_max_filesize = 64M
post_max_size = 64M
The problem in my case is the file I was trying to upload.
That PDF file was corrupted. I repaired the PDF file with some online PDF file repairing tool and it worked fine.
In case if you have shared server, you can add php.ini file and add following lines to it.
memory_limit = 1024M
max_input_vars = 2000
upload_max_filesize = 300M
post_max_size = 300M
max_execution_time = 990
This will work fine.
In additional to the above, make sure that
LimitRequestBody
in your .htaccess file is set properly or disabled altogether. 0 means unlimited
Docs here
Apache LimitRequestBody Directive

Uploading files to server using php

I can successfully upload files upto 3-4 MB. But when I try to upload files greater than 4 MB, it starts upload for sometime and then shows "This webpage is not available" error. I have hosted the site in 000webhost. But in localhost, I can easily upload larger files as well. Please help me out of this.
You need to set the value of upload_max_filesize and post_max_size in your php.ini :
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
(and restart apache)
I believe that you have
Enough permission to upload files
And increased upload_max_filesize and post_max_size
upload_max_filesize = 40M
post_max_size = 40M
Note :
000webhost.com is a free hosting site and you can't expect good speed and it would fail in most cases. If you want to see good response better try in a paid hosting or try in some free app hosters like heroku
Update according to user's Comment :
I can do that in localhost. But where can I find the php.ini file as I have already hosted the site
You can't find the php.ini in online server. But you can set it using .htaccess files and other few ways..
Create a .htaccess file and inside it have the following code, then you can achieve your need.
php_value upload_max_filesize 40M
php_value post_max_size 40M

PHP - can't upload files bigger than 20MB

I have a problem with adding multiple files on my server. Everything works fine on smaller files (<20MB). They are uploading on the server and into my data base without any errors or problems. But when I want to add files bigger than 20MB (for example 10 files, 2,2MB each) uploading doesn't work. There is no error, just nothing is sended via _POST. I tried to change php.ini files, but it is still the same problem.
I've increased:
max_execution_time to one hour
max_file_uploads to 100 files
memory_limit to 512M
output_buffering to 30M (earlier I've turned it off)
post_max_size to 64MB
upload_max_filesize to 64M
The website is on OVH hosting, so every changes I've made in .user.ini file. When I'm trying phpinfo() it shows values which I've changed.
Anyone knows any solution?
in your .htaccess file, this allow me to add upto 2 GB
php_value upload_max_filesize 2048M
php_value post_max_size 2048M
php_value max_execution_time 259200

Changing the upload limit in php

I am developing a CMS where the clients will need to upload files larger than 2mb - up to 10mb at least. I have changed the details in the php.ini file and I cannot see anywhere else that the problem might be. Any help?
Cheers
Here's what I recommend changing (assuming Apache & PHP):
I've found this works well for up to about 30mb attachments
PHP Settings
max_execution_time = 120
max_input_time = 120
memory_limit = 30M
post_max_size = 30M
upload_max_filesize 30M
file_uploads = On (although it sounds like you already have this turned)
Apache Settings
LimitRequestBody 31457280
You need to set upload_max_filesize, post_max_size and memory_limit appropriately. post_max_size must be larger than upload_max_filesize, because there needs to be memory allocated for the request headers as well as the file payload.
In your php.ini:
; Maximum allowed size for uploaded files.
upload_max_filesize = 50M
; Maximum size of POST data that PHP will accept.
post_max_size = 50M
What errors are you getting in your error log once these have been done? Is it possible that your uploaded file is running foul of the memory limit on the script?
You can set the memory limit higher for this particular script by including the following line in your script:
ini_set("memory_limit","75M");
Make sure you changed upload_max_filesize AND post_max_size
As long as you have restarted your web service (ie apache) then the changes should take effect, however if you are developing for anyone other then yourself then instead of changing the php.ini I would add this to the upload script:
ini_set('upload_max_filesize', '10M');
as some people may not be able to modify php.ini this will change it just for the page it is on.

Categories