dtstnjl898781429 2014-03-15 17:26
浏览 94

在IE8 / 9中使用blueimp文件上传插件的jQuery $ _FILES数组为空

There's lots of questions on StackOverflow related to the Blueimp file upload plugin in IE8/9, but I can't find anything directly related to my problem.

I'm using IE10 in the IE8/9 simulator mode. Every time the PHP $_FILES array is empty. I'm including jquery.iframe-transport.js and it loads fine. There are no JavaScript errors. The $_FILES array is just empty.

I've tried commenting out the dataType: 'json', line which was recommended in another semi-related question, but that did not help.

Not sure what to do here and can't find anything that relates to this. Any help is appreciated.

Here's the JavaScript:

$('#photo-file').fileupload(
    {
        url: 'photos/upload',
        dataType: 'json',
        autoUpload: true,
        acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
        maxFileSize: 8000000 // 8 MB
    }
)
.on(
    'fileuploadadd',
    function (e, data)
    {
        console.log('fileuploadadd');
        if (total_photos_queue < available_photos)
            total_photos_queue++;
        else
            return false;
    }
)
.on(
    'fileuploadsubmit',
    function (e, data)
    {
        console.log('fileuploadsubmit');
        progress_bar.width('0%');
        progress_bar.fadeIn();
    }
)
.on(
    'fileuploadprogressall',
    function (e, data)
    {
        console.log('fileuploadprogressall');
        var progress = parseInt(data.loaded / data.total * 100, 10);
        progress_bar.css('width', progress + '%');
    }
)
.on(
    'fileuploaddone',
    function (e, data) {
        console.log('fileuploaddone');
        $.each(
            data.result.files,
            function (index, file)
            {
                if (file.filename)
                    photo_uploaded(file.id, file.filename, file.subdir);
                else if (file.error)
                    console.log('error: ' + file.error);
            }
        );
    }
)
.on(
    'fileuploadstop',
    function (e) {
        console.log('fileuploadstop');
        progress_bar.fadeOut();
    }
)
.prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');

The PHP is simply (for debugging):

var_dump($_FILES); die();
  • 写回答

1条回答 默认 最新

  • doucheng1063 2014-03-16 20:06
    关注

    I figured this out, so for anyone having a similar issue here is how I solved it.

    In my .on('fileuploadsubmit', function(e, data){ .. }) event I was setting the <input type="file"> to disabled to prevent users from submitting a file while it's already uploading (I removed that bit from the example JavaScript snippet in the original post because I didn't think it mattered). IE8 and IE9 didn't like this. Putting the input disabling code in a setTimeout() with a delay of 100 milliseconds solved it.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错