I'm trying to upload some files to an ftp server from an ASP.NET page. Everything is ready however I would like to use an open file dialog to select the files I want to upload. How can I enable file upload to select multiple files, and if I can't, can I simply use the OpenFileDialog like a normal windows forms application ?
Thanks in advance
The issue is that in the context of a web application, you post data as a KeyValuePair. So a single <input type="file" name="Something" />
element can contain only one file because it is only one key.
An OpenFileDialog
would be executed server side in a window there; the client would never see it.
Your options are to either limit to 1 file (and have a button to add another file upload), or move to a gmail like approach where you use a flash / plugin to get that functionality.
The standard HTML browse dialogue won't let you. However, there's a video on the official ASP.NET site called Multiple File Uploads in ASP.NET 2 that you should look at. There's some code based on that here .
Generally you would either use a Flash or JavaScript/AJAX based solution. There are plenty of controls available that can do this eg.
Just google 'multiple file upload' for far more.
我也在这一点上进行了研究,但是由于一个文件控件的局限性是一次只能选择一个文件,因此无法在一个文件控件中选择多个文件,因此您将需要多个文件控件来导入多个文件
将OpenFileDialog的MultiSelect
属性设置为true。
Have a look here on how to upload multiple files. You have multiple FileUpload controls and use HttpFileCollection to get the files.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=68&AspxAutoDetectCookieSupport=1
You may want to look at these SO posts:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.