問題描述
我想為我的一個項目添加類似 gmail 的文件上傳功能.有人可以幫我解決這個問題嗎?
I want to add gmail-like file upload functionality for one of my projects. Can anybody help me with this?
我的應用程序是在 vb.net 中構建的.
My application is built in vb.net.
我將不勝感激任何形式的幫助或指導.
I would appreciate any kind of help or guidance.
謝謝
推薦答案
查看 SWFUpload,它本質上是一個 javascriptapi to flash 絕對優越的文件上傳處理能力.在瀏覽器最終趕上之前最好的事情.
Check out SWFUpload, which is essentially a javascript api to flash's absolutely superior file upload handling capabilities. Best thing out there until the browsers finally catch up.
來自鏈接:
- 在對話框中通過 ctrl/shift-selecting 一次上傳多個文件
- 所有事件的 Javascript 回調
- 在上傳開始前獲取文件信息
- 使用 XHTML 和 css 樣式上傳元素
- 使用 HTML 上傳文件時顯示信息
- 無需重新加載頁面
- 適用于所有支持 Flash 的平臺/瀏覽器.
- 如果 Flash 或javascript 不可用
- 在上傳開始前控制文件大小
- 只在對話框中顯示選擇的文件類型
- 上傳隊列,開始上傳前刪除/添加文件
演示
--iframe 上傳 -----
----- iframe upload -----
首先,您希望在您的頁面上有一個 iframe.這用于服務器通信.您稍后會隱藏它,但現在,讓它保持可見.給那個 iframe 一個 name 屬性,比如uploader"之類的.
To start, you want to have an iframe on your page. This is meant for server communication. You'll hide it later, but for now, keep it visible. Give that iframe a name attribute, like "uploader" or something.
現在,在您的表單中,將目標設置為 iframe 的名稱,并將操作設置為您在服務器上接受文件上傳的腳本(就像帶有文件上傳的普通表單一樣).在該表單內添加一個帶有文本添加文件"的鏈接.設置該鏈接以運行 javascript 函數,該函數將向表單添加新輸入.這可以通過 DOM 完成,但我會推薦一個 JavaScript 庫,例如 jquery.
Now, in your form, set the target to the iframe's name and the action to a script you have on the server that will accept a file upload (like a normal form with a file upload). Add a link inside that form with the text "Add File". Set that link to run a javascript function which will add a new input to the form. This can be done via the DOM, but I would recommend a javascript library like jquery.
將新文件輸入添加到表單后,將該輸入的模糊事件設置為將提交表單的 javascript 函數,然后定期檢查它的輸出.讀取 iframe 可能會很棘手,但這是可能的.
Once the new file input is added to the form, set the blur event of that input to a javascript function that will submit the form and then check it periodically for output. Reading an iframe can be tricky, but it's possible.
讓您的文件上傳腳本輸出完成".或上傳完成時的文件名或其他內容.
Have your file upload script output a "Done." or a filename or something when the upload is complete.
每隔一秒左右檢查一次,直到有內容為止.獲得內容后,終止計時器并將文件輸入替換為文件名(或文件上傳")或其他任何內容.
Check it every second or so until there is content. Once you have content, kill your timer and replace the file input with the name of the file (or "File Uploaded") or whatever.
用 css 隱藏你的 iframe.
Hide your iframe with css.
這篇關于如何為我的網絡應用獲取類似 Gmail 的文件上傳?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!