Upload large files to Amazon S3 directly and add o

2019-09-14 23:38发布

问题:

I want to create a single web form where a user provides a large file, and some information like title and description. When the form is submitted, the file should be directly uploaded to Amazon S3 (without uploading it to the web server), while the information is added to the database using PHP.

How would I go about doing this? I know I could use the direct upload post solution, but then I wouldn't be able to add the other information to the database.

回答1:

I would implement an ajax submit of the file on S3 (using the direct upload parameters, eventually) and then submit all the other fields to your webserver in a second step (even not ajax, of course).

You could also use an hidden field in your form to submit the new S3 link (which you can retrieve after the ajax upload is completed), since I guess you need to store it together with all the other data.