Uploadify不适用于IE和Chrome浏览器,并提供HTTP错误

时间:2011-09-15 12:31:00

标签: javascript jquery uploadify

我已经设置了uploadify,可以在Firefox上运行多个图片上传。但是,它不适用于IE和Chrome。

代码:

    $("#file_upload").uploadify({
        'uploader'  : '/examples/uploadify/uploadify.swf',
        'script'    : '/examples/uploadify/uploadify-spotlight.php',
        'cancelImg' : '/examples/uploadify/cancel.png',
        'method'    : 'post',
        'debug' : true,
        'preventCaching'  : true,
        'multi'          : true,
        'fileExt'     : '*.jpg;application/jpeg;application/png',
        'fileDesc'    : 'Image Files (.JPG, .GIF, .PNG)',
        'sizeLimit'   : 62914560,
        'removeCompleted': false,
        'onSelectOnce'   : function(event,data) {
          $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
        },
        'onAllComplete'  : function(event,data) {
          //successfull
        },
        'onError' : function (event, ID, fileObject, errorObj){
             //not Successfull
        }
});

调试:在Chrome控制台中没有说什么。

1 个答案:

答案 0 :(得分:2)

好的,我已经弄清了原因。这是由于session。由于闪存是与后端脚本通信的,因此它不会传递会话变量。

你需要明确表达:

$("#upload").uploadify({
  ...
  'scriptData': { 'session': '<?php echo session_id();?>'}
  ...
});

然后在后端脚本中调用会话ID:

if ($_REQUEST['session']) session_id($_REQUEST['session']);