I trying upload large file (over 200mb) via FormData and xmlHTTPRequest like this
var fd = new FormData;
fd.append('files[]', file);
xmlHttpRequest.open("POST", url, true);
xmlHttpRequest.send(fd);
in php script i have
<?php
var_dump("IN");
var_dump($_FILES);
out:
IN
array()
Request wait 10 second and finish. With smaller files all good, without FormData (simple ajax from) all good. all settings in php.ini have max value. what's wrong?
if it can help, this is my request header:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Cache-Control no-cache
Content-Length 294561150
Content-Type multipart/form-data
Host test1
Referer http://test1/
User-Agen Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0
X-Requested-With XMLHttpRequest
Response header:
Connection close
Content-Encodin gzip
Content-Length 51
Content-Type text/html
Date Sat, 29 Jun 2013 23:03:26 GMT
Server Apache/2.2.22 (Ubuntu)
Vary Accept-Encoding
X-Powered-By PHP/5.4.17RC1
My /etc/php5/apache2/php.ini:
file_uploads = On
upload_max_filesize = 512M
max_file_uploads = 20
max_input_time = 10000
memory_limit = 2048M
max_execution_time = 10000
post_max_size = 1024M
My scripts link: http://www.megafileupload.com/en/file/430866/test1-tar-gz.html
PS It's run all times 10 seconds and then finish.
Without seeing your php.ini file, these are things that will affect upload and you need to change them accordingly
file_uploads
upload_max_filesize
max_input_time
memory_limit
max_execution_time
post_max_size
All those settings have to have a reasonably high setting for larger files. Becareful not to make your memory_limit too high which can be dangerous. I'd maybe do 128MB
. max_execution_time
is forgotten by many and the default is 30
secs. Not long enough for large files. I set mine to 1000
since I handle large videos. It is a common reason why the script doesn't finish and will finish prematurely. You may or may not have to restart your web server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.