【发布时间】:2011-03-28 15:27:58
【问题描述】:
我正在使用自定义 ashx 处理程序来处理文件上传。在本地运行时,文件上传正常。
当我在 Web 服务器上使用相同的设置时,我收到 "Index out of range" 错误。
在萤火虫中,我在发布数据中看到文件的二进制内容,并且文件名也在查询字符串中传递。
有人见过这个吗?
我确定它是小事,但它把我逼到了墙角。
更新:取得了一些进展。我发现我遇到了两个不同的错误。一个来自 FF / Chrome,一个来自 IE。我现在专注于 FF,只是因为 firebug 使调试更容易。现在我收到一个错误“找不到路径'C:\inetpub\wwwroot\'的一部分”
更新 2: 让这个在 FF/Chrome 中工作。原来 IE 和 FF/Chrome 发布数据的方式不同。
更新 3:这是 IE 开发工具中网络分析器的输出:
Request header:
Key Value
Request POST /Secured/UploadHandler.ashx? HTTP/1.1
Accept text/html, application/xhtml+xml, */*
Referer http://cms.webstreet.co.il/Secured/fileUpload.aspx
Accept-Language he-IL
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type multipart/form-data; boundary=---------------------------7db13b13d1b12
Accept-Encoding gzip, deflate
Host cms.webstreet.co.il
Content-Length 262854
Connection Keep-Alive
Cache-Control no-cache
Request body:
-----------------------------7db13b13d1b12
Content-Disposition: form-data; name="qqfile"; filename="P-Art_Page_Digital.jpg"
Content-Type: image/jpeg
<Binary File Data Not Shown>
---------------------------7db13b13d1b12--
【问题讨论】:
-
你有一些示例代码吗?我遇到了一些类似的问题,我认为我的问题与 Cassini 和 IIS 中的路径映射之间的差异有关。
-
我考虑过,但后来我在远程文件系统上使用了绝对路径,它也不起作用。我可以尝试使用本地 iis,但我明天才会这样做。
-
您不可能使用
Request.Files[0].FileName属性保存文件,是吗?旧版本的 IE 实际上发送了文件的整个路径 (c:\folder.image.jpg) 而不仅仅是名称 (image.jpg) -
不。文件集合为空。 Request.Files[0] = null。
-
有谁知道 IE8 和 IE9 之间的 AJAX 行为是否发生了变化?也许这就是问题所在。
标签: asp.net file-upload ashx