开发者

How does dropbox.com's multiple file upload feature work?

开发者 https://www.devze.com 2023-02-14 17:43 出处:网络
The website frontend for Dropbox allows one to upload multiple files from the same dialogue box. How does this work exactly? Is it some cutting-edge HTML tag? Or fancy JavaScript? Or a Flash / Java e

The website frontend for Dropbox allows one to upload multiple files from the same dialogue box.

How does this work exactly? Is it some cutting-edge HTML tag? Or fancy JavaScript? Or a Flash / Java embedded applicati开发者_高级运维on?

It's amazing and I didn't think it was actually possible!

Please advise.


Last time I checked it was Flash. It uses ActionScripts FileReference class. Check out http://swfupload.org/ if you want to add this kind of functionality to your own application.

What surprised me the most in the beginning was that you could have this kind of functionality with no message asking for user permission whatsoever. I was used to java applets for this kind of feature, and to access the file system they need to be signed, and ask for user permission before execution. The trick with Flash is that you just :

  • open a FileDialog to select files
  • the only thing you can do with the selected files is uploading

So there is no security risk for the user, as the programmer never gets access to the file system.


i just checked this... when you right-click on the upload files button you can see that it is a flash movie. So this is some flash thing.

What you can do is:

<form action="file-upload.php" method="POST" enctype="multipart/form-data">
Send these files:<br>
<input name="userfile[]" type="file"><br>
<input name="userfile[]" type="file"><br>
<input type="submit" value="Send files">

where file-upload.php iterates through the files and uploads them.

for adding more files you could create the input elements via javascript.

there is no special html element to do this.


Most multi-upload solutions (dropbox isn't the only one, nor the first) utilize a flash built upload handler with any type of server side code to process / handle the upload.

There are other alternatives too, using AJAX, like

  • Fancyupload (http://digitarald.de/project/fancyupload/)
  • Ajax Upload (http://valums.com/ajax-upload/)
  • etc;

Search on google for ajax upload for more, or go the swf route by searching for flash upload. There are a lot of tutorials written for your flavour or language as well (whatever you choose)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号