Internet Explorer: FileUpload control doesn't recognize files with long file names

眉间皱痕 提交于 2019-12-11 11:58:36

问题


You might think after reading this question that it is somehow unrealistic but the below situation is there in one of our production applications.

One of our users reported that he is getting an error if he tries to upload files with too long names, we got to fix that by limiting file names to not exceed 255 chars including file extensions. But we faced another weird behavior that is there in Internet Explorer only.

If user tries to upload a file that its length including extension is 255 chars, FileUpload is not picking the file (i.e. doesn't recognize file) and the textbox that shows the filename remains blank. This is valid in IE8, IE9 and IE 10 ! This is valid in ASP.NET or SharePoint solutions.

I tried to upload the same file in GMail, I was able to upload it in all browsers except Internet Explorer which means it is something related to IE.

Any suggestions? any fixes?


回答1:


Unfortunately, it seems to be (have been?) a windows "feature".

See : http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx#maxpath

A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage.

I guess you should avoid manipulating files which full path exceeds 260 chars,

Don't know if it would work using the "\?\" very long name prefix in the file input text box.

Hope this will help.



来源:https://stackoverflow.com/questions/14898799/internet-explorer-fileupload-control-doesnt-recognize-files-with-long-file-nam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!