How can I get Gmail-like file uploads for my web app?

前端 未结 10 1429
清歌不尽
清歌不尽 2020-12-04 16:09

I want to add gmail-like file upload functionality for one of my projects. Can anybody help me with this?

My application is built in vb.net.

I would apprecia

10条回答
  •  [愿得一人]
    2020-12-04 16:45

    Gmail's code is difficult to find your way around, but if I had to guess, this is how it works:

    • When you click "attach another file", it inserts a regular input type file control. On IE, it may also programmatically trigger the click event on the "browse" button so the file dialog opens immediately (it doesn't do this on firefox, and I don't have IE handy, but I believe IE allows for this)
    • After you select a file, it detects the change event of the input control, and starts a timer.
    • When the timer triggers, it detaches the input element from the form, and adds it to a different form in a hidden iframe, placing a simple link in the main (visible) form. The hidden iframe is then submitted to upload the file. (It may also clone the input element, but I haven't tried whether this works.)

提交回复
热议问题