Question

my goal is to let users select multiple files in frontend, but i prefer to upload them separately. I would like to save original file selection and post form with one file each. But it does not work to change the property files (via jquery).

var fileIndex = 0;
var allFiles = $('input#file_temp').prop('files');
$('input#file_temp').prop('files', [allFiles[fileIndex]]);

after that, "files" property holds all files as before. why? how to solve this to post one file only?

Was it helpful?

Solution

That is because the .prop('files') is a FileList and is read-only which means you can't change it via JavaScript. See http://www.w3.org/TR/FileAPI/#dfn-filelist for documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top