在浏览其他页面时上传多个文件-如何? [英] Upload multiple files while navigating other pages - howto?

查看:85
本文介绍了在浏览其他页面时上传多个文件-如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网站,我希望允许用户在浏览网站时上传多个文件.

I'm creating a website and I'd like to allow users to upload multiple files while they navigate the website.

上传完成后,最好触发Javascipt事件,以允许用户指定与上传文件有关的其他信息(例如照片位置,标签等) 无论如何,必需的功能是:

When the upload completes, it would be nice to have a Javascipt event triggered, to allow the user to specify additional info related to the uploaded files (eg. photo location, tags, etc) anyway, the required features are:

  1. 单个上传操作允许多个文件
  2. 显示可选的进度指示器(至少以上传的y个文件中的x个"方式)
  3. 做到这一点而不会将用户束缚到单个页面上

如何实现这些功能? 任何建议都将不胜感激!

How can I implement these features? Any suggestion is greatly appreciated!

修改

如果使用弹出窗口来处理上传,我该如何:

In the event of using a popup window to handle uploads, how can I:

  1. 通知用户(在母版"页面上)上传已完成,或者出现错误?
  2. (更重要的是)将$ _FILES数组传递给弹出窗口?我希望用户能够在主窗口上单击上传",或者无论如何都可以从主窗口开始上传(例如,在主窗口上拖放文件).

推荐答案

由于浏览该网站会切换页面,而且您的网站不太可能进行完整的Ajax导航,因此也许可以通过某种方式在第二个弹出窗口中上传文件窗户.虽然不确定如何实现,但是由于您一次需要上传多个文件,恐怕您一定会使用Flash.

Since navigating the site will switch pages and it's unlikely that there's a full ajax navigation on your site, maybe it could help to somehow upload the files in a second popup window. Not sure how (if) it could be implemented, though, but since you need to upload multiple files at a time I'm afraid you're bound to use flash.

编辑

所以解决方案可能看起来像这样:

So the solution could look like this:

当用户单击选择文件"按钮时,您会弹出一个新窗口,在该窗口中,他将能够实际选择文件(如果需要多文件上传,则通过Flash).并使用postMessage通知上传进度.尽管在这种情况下 postMessage无法在IE中工作,但是您可能可以通过某种方式发送消息发送到服务器,然后从服务器返回到页面.

When a user clicks a "select files" button you pop out a new window where he'll be able to actually select files (via flash if multifile upload is necessary). And to notify of upload progress use postMessage. Though postMessage isn't going to work in IE in this case, but probably you could somehow send the message to the server and from the server back to the page.

另一个疯狂的想法是不使用弹出窗口,而是让用户在她最初的页面上选择文件,但是一旦用户选择了文件,就在页面上建立所有链接target=_blank以进行任何后续导航发生在另一个标签中.我知道这很hacky,并不完全用户友好,但可能会有所帮助.

Another crazy idea is not to use a popup window, but let the user select the files on the page she was first, but once the user selects the files make all the links on the page target=_blank to make any subsequent navigation happen in another tab. I know it's hacky and not exactly user-friendly, but probably could help.

无论如何,我都会事先通知用户在这两种情况下都会出现一个新窗口.

In any case I would inform the user beforehand that a new window will appear in both scenarios.

EDIT2

还有一个更疯狂的想法.当用户选择文件并单击链接时,创建一个iframe,该iframe将覆盖整个页面并将其隐藏在其下的原始页面,并使链接在iframe中打开.但是它看起来更加骇人听闻,似乎您会遇到很多麻烦.

And an even crazier idea. When the user selects the files and clicks a link create an iframe which will cover the whole page and hide the original page beneath it and make the links open in the iframe. But it looks even more hackish and it seems you'll have much trouble with it.

这篇关于在浏览其他页面时上传多个文件-如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆