我正在为我们的公司 Intranet 用户开发 ASP.NET Web 应用程序。我有一个表单,用户应该在本地网络上提供文件的路径(例如“\localServer\someFolder\someFile.ext”),而不上传实际文件。问题是用户不想键入整个文件路径并希望使用某种可视化浏览对话框。
标准 HTML <输入类型=文件> element 允许浏览文件,但大多数浏览器(IE 除外)不允许访问文件的完整路径,所以我认为它应该由一些外部组件来完成,如 Silverlight、Flash、Java applet 等。
我尝试过使用 Silverlight 来执行此操作,但在尝试使用 Silverlight 的 OpenFileDialog 类访问文件的完整路径时遇到 SecurityException。
这个java小程序 http://jumploader.com/demo_images.html 似乎做了类似于我的事情正在寻找,但它专注于上传文件 - 我只需要能够获取文件的完整路径并将其作为字符串传递到服务器。
任何建议将不胜感激。
I'm working on an ASP.NET web application for our corporate intranet users. I have a form where a user should provide a path to the file on the local network (something like "\localServer\someFolder\someFile.ext") without uploading the actual file. The issue is that users don't want to type the whole file path and want to use some kind of visual browse dialog.
The standard HTML <input type=file> element allows to browse for a file, but most of the browsers (except for IE) don't allow to access file's full path, so I think it should be done by some external component like Silverlight, Flash, Java applet etc.
I tried to do it with Silverlight, but I'm getting a SecurityException when trying to access file's full path using Silverlight's OpenFileDialog class.
This java applet http://jumploader.com/demo_images.html seems to do something similar to what I'm looking for, but it's focused on uploading files - I only need to be able to get file's full path and pass it to the server as a string.
Any suggestions would be appreciated.
发布评论
评论(2)
Telerik ASP.NET AJAX RadFileExplorer 具有您正在寻找的功能:
http://www.telerik.com/products/aspnet-ajax/fileexplorer.aspx
您可以使用他们的自定义文件内容提供程序将 GUI 连接到服务器的文件系统。
http://demos.telerik.com/aspnet -ajax/fileexplorer/examples/server-sideapi/dbfilebrowsercontentprovider/defaultcs.aspx
Telerik ASP.NET AJAX RadFileExplorer has the functionality you're looking for:
http://www.telerik.com/products/aspnet-ajax/fileexplorer.aspx
You can use their Custom File Content Provider to hook the GUI to your server's file system.
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/dbfilebrowsercontentprovider/defaultcs.aspx
Flash 的上传功能应该可以实现这一点。 SWFUpload 有一个 API,您可以从 JavaScript 访问该 API 以提取所选文件名,而无需实际上传任何内容。请参阅此处的文档,例如
getFile()
:This should be possible with Flash's uploading capabilities. SWFUpload has an API that you may be able to access from JavaScript to extract the selected file name without actually uploading anything. See docs here, for example
getFile()
: