简体   繁体   English

跨浏览器的目录上传方法

[英]Cross-browser method for directory uploading

If this can only be done in some browsers, I'd still like to know how... 如果只能在某些浏览器中完成此操作,我仍然想知道如何...

Basically, I want to have a drag-and-drop feature where users can drag files to a drop zone and then hit "upload" and have the files uploaded to the server. 基本上,我希望具有拖放功能,用户可以将文件拖放到放置区,然后单击“上传”,然后将文件上传到服务器。

I was pondering the possibility of having the option to drag an entire folder to the drop zone and uploading all of the folder contents (preferably skipping any hidden or system folders). 我正在考虑是否可以选择将整个文件夹拖到放置区并上载所有文件夹内容(最好跳过任何隐藏或系统文件夹)的可能性。 I can imagine how this would be done via javascript by simply traversing the folder for files (and sub-folders) and adding those locations to the upload list, but I'm pretty sure that would violate some basic policies (for good reason). 我可以想象通过简单地遍历文件(和子文件夹)的文件夹并将这些位置添加到上传列表中,如何通过javascript做到这一点,但是我敢肯定这会违反一些基本策略(有充分的理由)。 But I'm not totally sure, since I know that Firefox 3.6 offers something along these lines. 但是我不确定,因为我知道Firefox 3.6提供了类似的方法。

I am thinking it might be possible if most browser policies make an exception for user-initiated events, but I might be dreaming. 我认为,如果大多数浏览器策略都将用户启动的事件排除在外是有可能的,但是我可能在做梦。

Anybody know for sure? 有人知道吗?

http://www.uploadify.com/ http://www.uploadify.com/

This will let you do multiple file upload, but not directory upload. 这样一来,您可以上传多个文件,但不能上传目录。 If you use a trusted applet, you can get the functionality you desire. 如果使用受信任的applet,则可以获得所需的功能。 It will require more than pure javascript, though. 不过,它不仅需要纯JavaScript。

Browsers (before the file API ) did not allow dropping things inside them from outside. 浏览器(在文件API之前)不允许从外部放入内部内容。

They would get intercepted by the browser and considered as drops to the browser engine.. 它们将被浏览器拦截,并被视为对浏览器引擎的丢弃。

Perhaps it can/could be done with flash or other embedded technologies.. but not directly through browser and javascript.. 也许可以/可以通过Flash或其他嵌入式技术来完成,但不能直接通过浏览器和JavaScript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM