問題描述
是否有允許從文件打開對話框中選擇多個文件并從 ASP.NET 網頁上傳它們的解決方案?我已經瀏覽過與此相關的以前的帖子,但想知道是否可以在不使用 flash 或 silverlight 等技術的情況下選擇多個文件進行上傳?提前致謝.
is there a solution that allows to select multiple files from the file open dialog box and upload them from ASP.NET web page? I have gone through previous posts related to this, but wondering if it is possible to select multiple files for upload without using the technologies like flash or silverlight? thanks in advance.
更新:需要明確的是,我需要通過按 shift 或 control 鍵一次在對話框中選擇一個文件夾中的多個文件.flash 上傳控件允許這樣做,但我正在尋找一個沒有 flash 的.看起來這是一個限制,如果不使用 flash 或 activex 控件是不可能的.
UPDATE: to be clear, I need to select multiple files in a folder in the dialog box at once, by pressing shift or control key. the flash upload controls allow this, but I am looking for one without flash. it looks like this is a limitation and not possible without using flash or activex controls.
推薦答案
HTML5 可以為文件的標準輸入標簽提供一個附加屬性:multiple.
It's possible with HTML5 which gives the standard input tag for files an additional attribute: multiple.
實現后如下所示:
<input type="file" id="input" multiple="true" />
...并準確地為您提供所需的內容.
...and give you exactly what you're looking for.
如果你加入一些普通的 Javascript,你甚至可以流式傳輸文件.
If you toss in some vanilla Javascript, you can even stream the upload of the file(s).
http://blog.new-bamboo.co.uk/2010/7/30/html5-powered-ajax-file-uploads
兩個缺點是:
- 這僅適用于支持 HTML5 (FF/Chrome/Opera/Safari) 的瀏覽器.您仍然需要針對各種 IE 的解決方案.
- 顯示的示例說明了如何在 PHP/Ruby/Django 環境中處理流文件.您必須弄清楚如何以 .Net 方式讀取上傳的文件.
我希望這會有所幫助,或者至少能讓你走上正確的道路.
I hope this helps or at least puts you on the right path.
這篇關于在 ASP.NET 中選擇要上傳的多個文件(最好不使用 flash)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!