html fileupload控件不会在Chrome中上传文件

时间:2012-05-17 16:32:01

标签: google-chrome file-upload

我有一个带有上传文件页面的asp.net应用程序(csv文件)。在这个页面中,我有一个更新面板,我有一个html文件上传控件 fileupload适用于IE和Firefox。使用chrome,我可以看到PostedFile.Filename =“bac.csv”, PostedFile.InputStream.Length = 80 但是当我将Inputstream复制到一个字节数组时,所有字节的值都为零。请记住,相同的代码适用于其他浏览器。

Fiddler也展示了不同的postdata。请参阅下面我在Fiddler中看到的Chrome和Firefox数据。显然,Chrome并未发布文件数据。我做错了什么,如何解决它。

Chorme数据

POST http://nap1557pdv:8081/Test.aspx HTTP/1.1 
Host: nap1557pdv:8081 
Connection: keep-alive 
Content-Length: 1080 
Cache-Control: max-age=0 
Authorization: Negotiate YIIHxQYGKwYBBQUCoIIHuTCCB7WgMDAuBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHgYKKwYBBAGCNwICCqKCB38Eggd7YIIHdwYJKoZIhvcSAQICAQBuggdmMIIHYqADAgEFoQMCAQ6iBwMFACAAAACjggXiYYIF3jCCBdqgAwIBBaEWGxRVUy5HTE9CQUwuU0NIV0FCLkNPTaIyMDCgAwIBAqEpMCcbBEhUVFAbH25hcDE1NTdwZHYudXMuZ2xvYmFsLnNjaHdhYi5jb22jggWFMIIFgaADAgEXoQMCASqiggVzBIIFb90TTnez5nz7PYYCHnFWHoUr0lL7EAB6ZoYVhl57Rw+YPVA4ETppBF7d+loFVEvph67qrU35Ivax10viOxneO+Lfw3MnJyt67jtpr7nLuObPOZ5q8iSgOXC413xymPmsaaUgGdA9Ngvz2pOE8OvEbJrkYMQQxZZBdtasWTJ8vTUNIgLgiQpJDfWscCVle/++kWWr4HMZbPM4epC9yA9rMl6SF9728tW0Q/3ZLdNnccxuWb+FMUxAd53H6sb6xIotw0ZBomZOwwf++p5+r47Fcpcp/e0d/MBaLEGBeGkYYPvTfeETcoFh1Z+r7mR34YzTe7ubw+13kDs9iAtAk+sSBZDuSe2v7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NClF3A1XgO4yfqcau3ZgCNMZsG6h7aYGWXGCd16KuoU87vOk/JBqd61+JgAHVAkAkIjwzXsNz/Q8KbDdh14NwiK7U2gHXnLW53nn6NTMvCF7xcAhltdmukBksHGMwTrjKA5Dx3F63Jk+8czIyjnrqfMLMZrvypErbYiAi7rsjfbCJ5TIQtzAUvGzUnDNsvncdi9Qw3HBi2NWhNf9polOaSvnfk/lv5QXWZZzY/iq4r0LPgAGR+Quckl00PMPneb+sXZsqzRhGkFSZQKIPHWxlf2DL+dVbMPYBzxqLcXgbKg1AHKzx+85m95JIJhgTm6t+KOwfAO7o2+qmwG1Rbe4VQNOlk7cMocZ2+gdUJ+l+hkRCNa9miwSj6pKt+ZoaeberFn2ii98FaokI9Ou6j9aKQtPrLuc3pIIBZTCCAWGgAwIBEqKCAVgEggFUlfYTsU7l+JAL3MNRQW0F++fScMJMOkdCC/qxS/E4ebyJyx6KCf3jg5PZYNje42R056D04HGzATVc6r7WlugfBfOOtTvlW55BBH6xocA9XRpb79Aorn7fnmEQ0Lli1Y2LymbD2ImnNeQqonjrQG6IcT5yZRVeDG4Xjv9dxKOM/AMYqIDq80PmoBxjpj21phGtt7kO3avxpwkPPSuTOJ8y5fbCwODdpwBWCZmQi80sL+VVISFiJGW+GG6GrMTiXJWMyWR/GMuCoGy4qaOGMeCcJSmAbaPCCHyMJuSn7HcLyq2QszJqW7h/873Wc0ed3xm+KjcSTWc7op1OVqnMbjKDg67I3Pa/OxoC3N1r4U19/NvP5pU1aF+Kx37MW8opo8yuMd6D/cD5I6uC7sWiy0gdeVE+mNJwAzogkbmuR12OmWKcOD0mjCd2a2aCCfgktjj31hOFpQ== 
Origin: http://nap1557pdv:8081 
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5 
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Referer: http://nap1557pdv:8081/Test.aspx 
Accept-Encoding: gzip,deflate,sdch 
Accept-Language: en-US,en;q=0.8 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 
Cookie: ASP.NET_SessionId=tprepknwc3ejjfvmvewhb3ea 

------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="ctl07_HiddenField" 


------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="__EVENTTARGET" 


------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="__EVENTARGUMENT" 


------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="__VIEWSTATE" 

/wEPZwUPOGNmMDIzYmE5MWZmZTE3yZ1szJcaImr6jsC8aAj3Jr/NJZHuYmM9v1nicrGvr1I= 
------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="__EVENTVALIDATION" 

/wEWAgKZhrWmDwLAtdSqDb+OpffaxhvDEvRAly4rTIajFqtN7G6bde9qDsAeL/uL 
------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="ctl00$MainContent$fileUploadChartData"; filename="bac.csv" 
Content-Type: application/vnd.ms-excel 

???????????????????????????????????????????????????????????????????????????????? 
------WebKitFormBoundaryoVCxaJFfHyYJTJUZ 
Content-Disposition: form-data; name="ctl00$MainContent$btnUploadDocument" 

Upload 
------WebKitFormBoundaryoVCxaJFfHyYJTJUZ-- 

Firefox数据

POST http://nap1557pdv:8081/Test.aspx HTTP/1.1 
Host: nap1557pdv:8081 
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip, deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Referer: http://nap1557pdv:8081/Test.aspx 
Cookie: ASP.NET_SessionId=i2egjzbii2d4ttz4uhripgz4 
Content-Type: multipart/form-data; boundary=---------------------------24464570528145 
Content-Length: 1104 

-----------------------------24464570528145 
Content-Disposition: form-data; name="ctl07_HiddenField" 


-----------------------------24464570528145 
Content-Disposition: form-data; name="__EVENTTARGET" 


-----------------------------24464570528145 
Content-Disposition: form-data; name="__EVENTARGUMENT" 


-----------------------------24464570528145 
Content-Disposition: form-data; name="__VIEWSTATE" 

/wEPZwUPOGNmMDIzYzRlZjk0NDk3xSjtNc5KxDS+sptXgXIwFbIwfngQQcicVPd0sZS0Hes= 
-----------------------------24464570528145 
Content-Disposition: form-data; name="__EVENTVALIDATION" 

/wEWAgKes7e9AgLAtdSqDeYF8SG+RG8hp8rFuJK7HrsxNq8TZlkf0m0bUTEzK9Pq 
-----------------------------24464570528145 
Content-Disposition: form-data; name="ctl00$MainContent$fileUploadChartData"; filename="bac.csv" 
Content-Type: application/vnd.ms-excel 

Symbol,Date,Open,High,Low,Close,Volume 
BAC,4/25/2012,8.21,8.35,8.19,8.23,563453 
-----------------------------24464570528145 
Content-Disposition: form-data; name="ctl00$MainContent$btnUploadDocument" 

Upload 
-----------------------------24464570528145--

2 个答案:

答案 0 :(得分:3)

这是Chrome 19.0.1084.46中的已知问题。见http://code.google.com/p/chromium/issues/detail?id=128574

答案 1 :(得分:2)

我们有完全相同的行为(jpeg文件只包含NUL值) 我们正在使用带有Windows身份验证的IIS网络服务器和Chrome 19.0.1084.46。 这是在周二谷歌更新Chrome时推出的。

现在我们恢复使用MSIE9