duanhuren5581 2013-06-29 22:38
浏览 236

尝试从formData上传大文件

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.

  • 写回答

1条回答 默认 最新

  • duan19780629 2013-06-30 01:41
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像