如何使用PHP和进度条直接将文件上传到S3如何使用、文件上传、进度条、直接

2023-09-11 10:02:49 作者:追风赶月

有一些类似的问题,但都没有在如何使用PHP与进度条直接将文件上传到S3一个很好的答案。它甚至有可能增加一个进度条,不使用Flash技术?

There are some similar questions but none have a good answers in how to upload files directly to S3 using PHP with progress bar. Is it even possible adding a progress bar without using Flash?

注:我指的是从上传客户端浏览器直接到S3。

NOTE: I am referring to uploading from client browser directly to S3.

推荐答案

我在我们的项目中做到了这一点。使用AJAX,因为标准的跨域的安全策略无法直接上传到S3;相反,你需要使用一个普通的表单POST或Flash。您将需要发送的安全策略和签名在一个相对复杂的过程,如 S3文档解释

I've done this in our project. You can't upload directly to S3 using AJAX because of standard cross domain security policies; instead, you need to use either a regular form POST or Flash. You'll need to send the security policy and signature in a relatively complex process, as explained in the S3 docs.