2013-11-22 18:41
浏览 120

从localStorage将文件发布到PHP $ _FILES

It's surprisingly hard to find a definitive answer to this, I'm 95% sure what I'm trying to achieve is impossible, but here goes:

I have a multipart/form-data upload form. A user selects a file, but has to be logged in before he can post the form. The user can log in via Twitter. If he does so after selecting a file, due to the redirect to/from Twitter, the file input will be empty.

I have a PHP script using the $_FILES array to move the uploaded file to its final destination. (A solution to my problem would be to save the file to a temporary folder before redirecting to Twitter, but I currently can't set that up).

I can store the selected file in localStorage using the FileSystem API (at least in modern browsers). But I obviously can't put that back in the input element. Now I'm at a loss: is there any way to get that file from my localStorage into the PHP $_FILES array?

图片转代码服务由CSDN问答提供 功能建议

很难找到明确的答案,我95%肯定我正在努力实现的目标 是不可能的,但这里是:

我有一个 multipart / form-data 上传表格。 用户选择文件,但必须先登录才能发布表单。 用户可以通过Twitter登录。 如果他在选择文件后这样做,由于重定向到Twitter或从Twitter重定向,文件输入将为空。

我有一个PHP脚本,使用 $ _ FILES 数组将上传的文件移动到最终目的地。 (我的问题的解决方案是在重定向到Twitter之前将文件保存到临时文件夹,但我目前无法设置它。)

可以使用FileSystem API将所选文件存储在localStorage中(至少在现代浏览器中)。 但我显然不能把它放回输入元素中。 现在我不知所措:有没有办法将我的localStorage中的文件导入到PHP $ _FILES数组中?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • droxy80248 2013-11-22 18:44

    Login to Twitter via ajax. This way you will stay on your current page and the file input will stay filled.

    点赞 打赏 评论

相关推荐 更多相似问题