Blueimp File Upload: single file upload

别说谁变了你拦得住时间么 提交于 2019-11-29 17:35:10

问题


I'm using Blueimp File Upload, how can I limit the upload to the last single element selected or (drag and) dropped? I already deleted the multiple attribute from input form and I set the maxNumberOfFiles option to the value 1 but if the first upload fails (because of the option maxFileSize or acceptFileTypes) the first element stays on top of the listed selected files (generated by template) and further files cannot be uploaded because they infringe the maxNumberOfFiles option. I'd desire that if an accepted file is upload and/or dropped, instead of being appended, it would replace the old (not accepted) file. I would also that the templates never prints more than one file when multiple files are dropped but only the first file.


回答1:


change input tag from:
<input type="file" name="files[]">
to:
<input type="file" name="file">




回答2:


Remove files array and remove multiple attribute:

<input id="fileupload" type="file" name="files[]" multiple>

to:

<input id="fileupload" type="file" name="file">



回答3:


Also change the multiple attribute if it is set from

<input type="file" multiple="" name="file">

to:

<input type="file" name="file">


来源:https://stackoverflow.com/questions/17451482/blueimp-file-upload-single-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!