Uploading files gives ERR_CONNECTION_RESET - php

When uploading files that are larger and take longer I get this response:
First time I try to upload a big file it seem to get: ERR_CONNECTION_ABORTED
after that it becomes ERR_CONNECTION_RESET
I checked all the upload limits etc all are 240seconds or higher and 256mb
I tried uploading 200mb file.
It always seems to happen at the same moment which is at 1 min.
There are no 60 second limits or anything in the phpinfo.
Also tried locally upping all the limits with no result.
Here is the main upload part. If additional info required I'll update the question A.S.A.P
Edit: Just came across this which is being used as well: SWFUpload
Getting error code 2038
Reinstalling flash doesn't work, neither do other browsers!

increase upload_max_filesize, max_input_time, and post_max_size an memory_limit in your php.ini. eventhought 200MB it is too big. if it is text/csv you might want to split the file in multiple files.

Related

Symfony2 Large File Uploads

I am trying to upload large files (5-8Mb) in my Symfony2 projects. For some reason anytime I upload anything larger than 2Mb the script bombs out. I can upload anything smaller than 2Mb. I have changed my php.ini file and php -i reflects these changes. I have restarted apache. What else do i need to do to make these larger file upload work. Thanks.
Ran into this issue before; try a chunking method of uploading. Most likely the script is exceeding the max execution time. So (without knowing what your logic looks like) have a function that sends the request (say 1MB) to another file that reads the input stream of the binary data within a while loop and continues to execute as long as the content length of the binary data does not equal zero. The while loop writes the data to a temp file and when it hits zero saves it to a permanent directory (or whatever you want to do from there) You can increase the max memory allowed and execution time in php.ini but this introduces security issues and is not recommended.
In your current PHP config, you probably limited the max upload size to 2M, so Symfony display the wrong error.
So check your php.ini file (/etc/php5/apache2/php.ini on Linux) and increase max_upload_size to fit your field :
upload_max_filesize = 20M
Don't forget to restart apache : apache2ctl restart
Now it should work !

Debugging techniques for a PHP script with many, many file uploads?

I have a PHP script which services a form that contains many, many file uploads. There's about 40 separate files being uploaded, although each one is less than 30 KB in size (so about a meg, total of actual data is being transfered).
I'm using CakePHP for this, if it somehow makes a difference.
The problem I'm having is that only 19 of the files are being uploaded (once they're uploaded I send out an email using GMail as an SMTP relay). I've checked the obvious things, such as listed here:
Can file uploads time out in PHP?
And I've got generous values for everything.
Could anyone suggest strategies to use for running down this problem and/or specific things to check?
I don't think it is a CakePHP issue. Apache and php have certain limits on number of files and max size of files that can be uploaded at a time. Also there will be max post size.
There are two ways to overcome this
You can override the settings in .htaccess file like
php_value upload_max_filesize 10M
php_value post_max_size 15M
php_value max_file_uploads 50
Change it in php.ini file and restart server.
So after much, much digging it looks like it was a problem with my SMTP setup. I couldn't tell you how or why, but the problem was that attempting to email a zillion emails (well, ~40) caused the PHP process to halt (no error messages, nothing). Running the exact same code under XDebug worked fine, and putting a quarter-second sleep() after each email appears to work.
(On a semi-related note: Is there a way to delete a StackOverflow question that you've asked? :) )

Php upload strange behavior

I was testing a little application I've made and I saw a strange behaviour when uploading multiple files that exceed some size.
I've read the bug mentioned here, but its way long ago. Strangely, I experience the same behaviour as the guy mentions in the bug.
When I upload, say 10 files in small size (50-300kb each) there is nothing wrong and the application works.
When I upload, two files with 1.5mb each, the application outputs an error message as the maximum allowed size is 512kb by the application (2mb in php.ini).
When I upload, multiple files that exceed 7 or 8 mb (I haven't tried to locate the exact size), php crashes without giving an error. Since I am in a development server, the errors are turned on and normally it displays the fatal errors.
When I upload, 1 file (say 25mbs), I still have the same error.
Well, I say it crashes because when I try to var_dump($_FILES) or even var_dump($_POST) the array returns null although it should have at least the submit name or whatever.
I've checked the tmp folder and the files are not being stored there as well. However, another strange behavior is that when I upload the files that exceed this mysterious limit, the browser seems to be uploading (I see the page takes a while to load), however, as mentioned, php acts like it does not know anything.
What could be the reasong of this strange behaviour?
PS: I'm working on my localhost (wampserver) on Windows 7 64-bit.
EDIT
Found the solution:
changing post_max_size from 8mb to something else solved my problem.
Here is a quote from the manual for those who need:
Sets max size of post data allowed. This setting also affects file
upload. To upload large files, this value must be larger than
upload_max_filesize. If memory limit is enabled by your configure
script, memory_limit also affects file uploading. Generally speaking,
memory_limit should be larger than post_max_size. When an integer is
used, the value is measured in bytes. Shorthand notation, as described
in this FAQ, may also be used. If the size of post data is greater
than post_max_size, the $_POST and $_FILES superglobals are empty.
This can be tracked in various ways, e.g. by passing the $_GET
variable to the script processing the data, i.e. , and then checking if
$_GET['processed'] is set.
That is error because you have very less upload limit - upload_max_filesize or post_max_size .
in php.ini just increase value of both to 200MB and you will nt receive this error
in the server there is a limit to send post. your should be 512kb. you can check in phpinfo();
i think its the parameter in php.ini upload_max_filesize. change to bigger size.

move_uploaded_file file disappears from tmp but does not reach destination

I have a really odd problem. I am using an upload form to upload videos. Sometimes I have to try twice to upload a file so I know it works but these files take a long time to upload so I don't want the end-user getting mad if the process fails. Also, this works 100% of the time on my test machine so I am thinking there is a config problem.
The file is 330mb and I set upload_max_filesize and post_max_size to 500mb. The max_execution_time and max_input_time are set to 60000 for testing purposes. memory_limit is what I think may be the problem. It is set to 128mb. Does it need to be higher to have a consistent upload success rate? Anybody know of any other problems that could cause things to go wrong?
You're right in assuming memory_limit is your culprit.
Taken from php.net.
post_max_size (int)
Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.
If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. (...)

In my php script larger file takes longer to upload and its bound by max_execution_time

In my php script larger file takes longer to upload and its bound by max_execution_time. when max_execution_time was set to 60 and i was uploading files under 1MB there was no problem. once i uploaded a file over 3MB i kept getting a blank screen with no error on it.
Dont worry all upload limits are set and yes php display errors is on. The only way i was able to determine the problem was when i set my max_execution_time to 360.
Once i did that there was time out and upload went through successfully.
my problem is that users are allowed to upload much later files and there is no way of nowing how long to set max_execution_time for.
If it is set really high, like how i have it set to 360 seconds, then that means in theory every php process can take up to 360 seconds to execute, which can be very bad.
Someone please help me. This is a file hosting script.
thanks.
Change the max execution time only when users are uploading files.
ini_set('max_execution_time', 360);
I believe setting the 'max_input_time' php.ini variable will only affect the parsing of input variables, which includes POSTed file uploads.

Categories