ASP.NET:FileUpload控件失败,文件名长

时间:2023-02-02 03:38:54

One of our clients is breaking the software in every way imaginable, and he's just discovered this one.

我们的一位客户正在以各种可想象的方式破解软件,他刚刚发现了这一点。

If the user tries to upload a file with a very long filename (I think the user is trying with a 180 character filename), the FileUpload control refuses to recognise it on IE7.

如果用户尝试上传文件名很长的文件(我认为用户正在尝试使用180个字符的文件名),则FileUpload控件拒绝在IE7上识别它。

Click on the Browse button, browse to the file, click on it, click the Upload button, and the text box that should show the filename is blank. Anyone know anything about this, fixes, etc?

单击“浏览”按钮,浏览到该文件,单击该文件,单击“上载”按钮,应显示文件名的文本框为空白。任何人都知道这件事,修复等等?

I managed to find this asp.net forums discussion on it, but it didn't shed much light on the issue.

我设法找到了关于它的asp.net论坛讨论,但它没有对这个问题有所了解。

The app is written in Visual Studio 2008, and this occurs in IE7, but not FF3 or Chrome. If I use either of the other two browsers, it fills the FileUpload control correctly, but breaks when you actually try to do the upload because the resulting filename/path is too long.

该应用程序是用Visual Studio 2008编写的,这发生在IE7中,但不是FF3或Chrome。如果我使用其他两个浏览器中的任何一个,它会正确填充FileUpload控件,但在实际尝试执行上载时会中断,因为生成的文件名/路径太长。

Enjoy Random

3 个解决方案

#1


This might not be specifically an ASP.NET or even an IE7 problem.

这可能不是特别是ASP.NET甚至是IE7问题。

Windows has a limit of 260 characters on full pathnames(*) and this can be easily reached with a few nested folders with long filenames, especially if you're starting in a user folder, which already has quite a long pathname (eg. 'C:\Documents and Settings\Brian Popalopadopaslopalos\My Documents' or 'Desktop').

Windows在完整路径名(*)上限制为260个字符,这可以通过一些具有长文件名的嵌套文件夹轻松实现,特别是如果您从一个已经有很长路径名的用户文件夹开始(例如'' C:\ Documents and Settings \ Brian Popalopadopaslopalos \ My Documents'或'Desktop')。

When you hit that limit, things start to go screwy. Renaming files, moving folders, searching and so on all start to go wrong in curious ways. It would be no surprise if browsers also failed and there is probably not much you can do about it.

当你达到这个极限时,事情开始变得棘手。重命名文件,移动文件夹,搜索等都以奇怪的方式开始出错。如果浏览器也失败并且你可能做的事情可能不多,也就不足为奇了。

(* - things are actually a bit more complicated than that, but still...)

(* - 事情实际上比这复杂一点,但仍然......)

#2


You would need to test this issue more and then put this in as a "Known Issue", giving the maximum size of filename you would accept.

您需要更多地测试此问题,然后将其作为“已知问题”放入,给出您可以接受的最大文件名大小。

Can they upload these files to hotmail? gmail? and file upload services?

他们可以将这些文件上传到hotmail吗? Gmail吗?和文件上传服务?

#3


A bit of further testing seems to make it look like it's the 260 character limit on pathnames exposing a bug in IE7.

一些进一步的测试似乎使它看起来像暴露IE7中的错误的路径名上的260个字符限制。

The test file I was using with a really long filename was sitting in my My Documents directory (so "C:\Documents and Settings\Random\My Documents"). Trying to Browse to this file was causing it to not fill in the FileUpload textbox.

我使用的文件很长的测试文件位于我的My Documents目录中(所以“C:\ Documents and Settings \ Random \ My Documents”)。尝试浏览到此文件导致它无法填写FileUpload文本框。

I moved the file to the root of my C: drive, and Browsed to that file, and it worked fine (and then crashed when I tried to actually upload it, because the path name would have been greater than 260 characters on the server, which is what happened if I was using FF3 or Chrome).

我将文件移动到我的C:驱动器的根目录,并浏览到该文件,它运行正常(然后当我尝试实际上传它时崩溃,因为路径名在服务器上大于260个字符,这就是我使用FF3或Chrome时发生的事情。

So, it looks like it's a combination of a few things showing up a bug in IE7.

因此,看起来它是IE7中出现错误的一些组合。

Thanks for the help.

谢谢您的帮助。

#1


This might not be specifically an ASP.NET or even an IE7 problem.

这可能不是特别是ASP.NET甚至是IE7问题。

Windows has a limit of 260 characters on full pathnames(*) and this can be easily reached with a few nested folders with long filenames, especially if you're starting in a user folder, which already has quite a long pathname (eg. 'C:\Documents and Settings\Brian Popalopadopaslopalos\My Documents' or 'Desktop').

Windows在完整路径名(*)上限制为260个字符,这可以通过一些具有长文件名的嵌套文件夹轻松实现,特别是如果您从一个已经有很长路径名的用户文件夹开始(例如'' C:\ Documents and Settings \ Brian Popalopadopaslopalos \ My Documents'或'Desktop')。

When you hit that limit, things start to go screwy. Renaming files, moving folders, searching and so on all start to go wrong in curious ways. It would be no surprise if browsers also failed and there is probably not much you can do about it.

当你达到这个极限时,事情开始变得棘手。重命名文件,移动文件夹,搜索等都以奇怪的方式开始出错。如果浏览器也失败并且你可能做的事情可能不多,也就不足为奇了。

(* - things are actually a bit more complicated than that, but still...)

(* - 事情实际上比这复杂一点,但仍然......)

#2


You would need to test this issue more and then put this in as a "Known Issue", giving the maximum size of filename you would accept.

您需要更多地测试此问题,然后将其作为“已知问题”放入,给出您可以接受的最大文件名大小。

Can they upload these files to hotmail? gmail? and file upload services?

他们可以将这些文件上传到hotmail吗? Gmail吗?和文件上传服务?

#3


A bit of further testing seems to make it look like it's the 260 character limit on pathnames exposing a bug in IE7.

一些进一步的测试似乎使它看起来像暴露IE7中的错误的路径名上的260个字符限制。

The test file I was using with a really long filename was sitting in my My Documents directory (so "C:\Documents and Settings\Random\My Documents"). Trying to Browse to this file was causing it to not fill in the FileUpload textbox.

我使用的文件很长的测试文件位于我的My Documents目录中(所以“C:\ Documents and Settings \ Random \ My Documents”)。尝试浏览到此文件导致它无法填写FileUpload文本框。

I moved the file to the root of my C: drive, and Browsed to that file, and it worked fine (and then crashed when I tried to actually upload it, because the path name would have been greater than 260 characters on the server, which is what happened if I was using FF3 or Chrome).

我将文件移动到我的C:驱动器的根目录,并浏览到该文件,它运行正常(然后当我尝试实际上传它时崩溃,因为路径名在服务器上大于260个字符,这就是我使用FF3或Chrome时发生的事情。

So, it looks like it's a combination of a few things showing up a bug in IE7.

因此,看起来它是IE7中出现错误的一些组合。

Thanks for the help.

谢谢您的帮助。