0

I am writing a web app, and not sure about how to upload multiple images. I want to make sure that either all images are uploaded successfully, or none of them.

One way is to upload them simultaneously in several thread. However, if one of the uploading process fails, it is difficult to cancel other process and remove uploaded images.

The solution I come up with is to combine the multiple files into a bigger file using some separator, and then server then separates it into original files.

Is my solution appropriate? Or are there any better solutions?

HanXu
  • 5,187
  • 5
  • 45
  • 72
  • Do you need that level of reliability? 99% of sites do a multipart HTTP POST and it just works. Why would upload fail? I don't see how making one big file would help: it is essentially what multipart does for you. – Ciro Santilli新疆棉花TRUMP BAN BAD Oct 25 '14 at 07:12
  • http://stackoverflow.com/questions/1175347/how-can-i-select-and-upload-multiple-files-with-html-and-php-using-http-post – Ciro Santilli新疆棉花TRUMP BAN BAD Oct 25 '14 at 07:15
  • @CiroSantilli, I am writing an iOS app, and was worry about by some accident some of the uploading process fails but others succeed. – HanXu Oct 25 '14 at 07:19
  • how could that happen? TCP ensures delivery, so it's all or nothing on the HTTP POST. And before making the post, the browser has to prepare the single POST request, so it's all or nothing on filesystem interaction. If you are really going to have huge ammounts of data / files, then maybe HTTP is not the right thing for you, but I think that is unlikely from a phone app. – Ciro Santilli新疆棉花TRUMP BAN BAD Oct 25 '14 at 07:23

1 Answers1

0

You will need some functional to check all files after all files have been uploaded. The simplest way - using standart form/multipart POST with all files in one request. But of course it is not so elegant. Another way - using one of popular and well tested plugin, for example - https://github.com/blueimp/jQuery-File-Upload

Semjon
  • 863
  • 6
  • 16