我正在使用Uploadify,以前现在正在使用的东西不是,我不知道为什么。每当我点击上传时,我都会收到HTTP错误。在Firefox中观看网络标签,看起来甚至不再向服务器发送任何内容。

我已尝试输入错误函数来帮助调试,但状态属性未定义。

$("#fileInput").uploadify({
                'uploader': '/scripts/upload/uploadify.swf',
                'script': '/Member/UploadImages/PerformUpload',
                'cancelImg': '/scripts/upload/cancel.png',    
                'multi': true,
                'simUploadLimit': 1,
                'fileDesc': "Images",
                'fileExt': "*.jpg;*. jpeg;*.bmp;*.png",
                'sizeLimit': 3000000,
                'onAllComplete':showFinishedLink,
                'onError': function (event, queueID ,fileObj, errorObj) {
                    var msg;
                    if (errorObj.status == 404) {
                       alert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');
                       msg = 'Could not find upload script.';
                    } else if (errorObj.type === "HTTP")
                       msg = errorObj.type+": "+errorObj.status;
                    else if (errorObj.type ==="File Size")
                       msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
                    else
                       msg = errorObj.type+": "+errorObj.text;
                    alert(msg);
                    $("#fileUpload" + queueID).fadeOut(250, function() { $("#fileUpload" + queueID).remove()});
                    return false;
                    },
            });

有什么想法吗?

有帮助吗?

解决方案

好的,想通了我正在使用的错误调试是旧的,我可以说errorObj.info来获取更详细的信息,说明它为什么不起作用。

这样做并且结果是404这意味着我尝试POST的脚本即使确实存在也没有被提取。听起来像路由问题......

案件结案!

只是为了添加更多信息 - 404是web.config文件中旧的默认登录URL的结果。

一旦我解决了这个问题,404就会变成302(查看IIS日志),因为该网站正在将我重定向到登录页面。

我的上传脚本位于网站的经过身份验证的区域,因此我需要使用此网站中描述的内容

使用用aspnet mvc闪烁

其他提示

我收到了仅在Firefox / Chrome中发生的302错误:IE8运行良好。问题原来是Netscape现在发送带有文件回发的auth cookie。我允许处理上传的.ashx文件在Web配置中使用匿名授权,并且没有其他问题。

<location path="UploadifyUploadHandler.ashx">
  <system.web>
    <authorization>
      <allow users="?"/>
    </authorization>
  </system.web>
</location>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top