简体   繁体   中英

JS, PLUpload: do not remove file from queue after upload?

I have a form with data and file input. I want to send all data along with file to given URL. If server response indicates error then user should see fields with errors highlighted. For this I'm trying to use PLUpload. But I experience following issues:

  1. I can't make it don't remove file from queue. In case of error user will have to fix his input and submit it again (possibly multiple times).

  2. multipart_data doesn't work with html5 adapter (I need support of mobile clients, so must use it). Data is potentially too long to be passed in query string.

Any ideas how to solve those? Or maybe another uploader?

PS I can't "just use iframe" because backend is an API that can't have any UI.

You can save uploaded file on server, and include info about uploaded file in response (with errors). On client side: if response from server contains info about file — you must to hide file input field and show some label, like: "File uploaded: tmp.pdf".

Pros:

  • user upload file once
  • you don't need to search some hacks for file uploading
  • user-friendly way

Cons:

  • Need to server-side work (save files, delete unused files, etc...)
  • Need to clent-side work (hide field, if file uploaded)

PS. I'm a non-native speaker, feel free to correct my message :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM