Dynamic creation of array input and download them to the server

The question was asked: 6 years 11 months ago   views: 20

I have one input type="file" name="files[]", and the rest are created dynamically. Clicking the submit button sends only the input type="file" name="files[]", which was not created dynamically! And the rest input not visible. Why? And how to fix it?

var massive = [];

addNewInput function(){

var ids = $("#divfiles input:file").last().attr("id");
var ind = ids.indexOf('_');
var ind2 = ids.substr(ind); 
 var ind3 = ind2.substr(1);
 var already_exists21 = 0;

var val = $("#fileinp_"+parseInt(ind3)).val(); 
var index = val.indexOf('.');
var val2 = val.substr(0,index);
if(already_exists21 == 0)
 $("#choosingfiles").append('<span id="files_'+(parseInt(in ind3))+'"><b>'+val+'</b><img src="../../images/delete_small.gif" onclick="deleteFile('+(parseInt(in ind3))+');" style="cursor:pointer;"></span>');
 var p = document.getElementById("divfiles");
 var y = document.createElement("input");
y.setAttribute("name",'massfiles[file_'+(parseInt(in ind3)+1)+']');
y.setAttribute("id",'fileinp_'+(parseInt(in ind3)+1)+");
 var t = massive.join(',');



<div id="divfiles" style="display: block;">
 <input type="file" name="massfiles[file_0]" id="fileinp_0" onchange="addNewInput();" />

Asked: Va9im Va9im 21-06-2012 в 11:17:17
@Va9im -, please, remove unnecessary code, css styles, optional html elements, comments, etc., And name variables normally massive.push(val); // this LOL :) - Zowie Zowie 21-06-2012 в 14:10:55
for the other bit... it's not too much... there appears below the name of the file which has been selected and next the cross to remove Impala which was selected this file - Va9im Va9im 21-06-2012 в 16:12:51
@Va9im - you don't understand, the name is massive... As if 1Сшник wrote :) - Zowie Zowie 21-06-2012 в 16:24:29

Answers   1


I'm not sure, but I think any tampering with the files in the browser is prohibited. UPD: including the dynamic change. Add type="file".

Answered: Nicolas Chabanovsky Nicolas Chabanovsky 21-06-2012 в 13:58:55
it is real... I know!!! But why not get XS(( - Va9im Va9im 21-06-2012 в 16:14:18