简体   繁体   English

JS,PLUpload:上传后不从队列中删除文件吗?

[英]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. 我想将所有数据和文件一起发送到给定的URL。 If server response indicates error then user should see fields with errors highlighted. 如果服务器响应指示错误,则用户应看到突出显示错误的字段。 For this I'm trying to use PLUpload. 为此,我正在尝试使用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). multipart_data不适用于html5适配器(我需要移动客户端的支持,因此必须使用它)。 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. PS我不能“仅使用iframe”,因为后端是一个没有任何UI的API。

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". 在客户端:如果服务器的响应中包含有关文件的信息,则必须隐藏文件输入字段并显示一些标签,例如:“文件已上传: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. PS。 I'm a non-native speaker, feel free to correct my message :) 我不是母语人士,请随时纠正我的信息:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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