Jiimmeh
Jiimmeh

Reputation: 73

Upload and zip several files using Plupload

I'm using a custom Plupload to be able to upload files on a website. I want to be able to create a zip when several files is being uploaded. Right now upload.php is uploading one file at a time, so i can't zip everyone at once. so how would you guys solve this problem?

Upvotes: 0

Views: 602

Answers (1)

Charles
Charles

Reputation: 51421

This should be pretty straightforward.

  1. Make sure you identify the user. Make them log in, or otherwise attach an identifier to them.
  2. Make sure that identifier is available to the script receiving the upload. Sessions are handy for this, but you can also use multipart_params if you have to.
  3. When processing an uploaded file, stash it somewhere and make a note of where it's been stashed. Stick the information about the file's location somewhere that you can gain easy access to later, like your database. If you don't have a database, what's wrong with you stick it in their session.
  4. When the user has finished uploading all of the files, have them proceed to the next page, which can then iterate over all of the uploaded files and create your zip.

Problems and caveats:

  • What happens to files that are uploaded, but that the user has abandoned?
  • What should the upload handler do if it can't identify the user?
  • Remind me again, why don't you just ask the user to create the zip file themselves? Seriously, there's zip support in every modern OS, usually even built in.

Upvotes: 1

Related Questions