0

Hi I am using http://www.fyneworks.com/jquery/multiple-file-upload/ for multiple upload file. But I need the same feature for some dynamic file uploader also. so I crated a function addElement() for that. The problem is the dynamic element is creating correctly but multiple upload feature is not working.

<title>Add Element</title>
<script language="javascript">
this.num = 1;
function addElement(){
$top = document.getElementById('top');
newId = document.createElement('div');
id = 'my'+this.num;
newId.setAttribute('id', id );
newId.innerHTML = "<input type='file' name='DocumentFiles2' class='multi' />";
$top.appendChild(newId);
this.num++;
 }
function removedThis( id ){
var d = document.getElementById('top');
d.removeChild(id);
 }
</script>
</head>
<body>
<input type='file' name='DocumentFiles[]' class='multi' /><!-- This one is working -->
<input type="button" name="button" value="Add Element" onclick="addElement()"  />
<div id="top" ></div>
</body>
</html> 

There is any alternative way to do this or make this to work.?

1
  • where is your upload code. you need to upload it by a loop Commented Feb 11, 2013 at 6:59

1 Answer 1

2

Add this code after calling addElement and removedThis and check

function addElement(){
     .....
     .....
     reinit();
}
function removedThis( id ){
     .....
     .....
     reinit();
}
function reinit()
{
    $('input[name="DocumentFiles[]"]').MultiFile({
    // your code
    });
}
Sign up to request clarification or add additional context in comments.

4 Comments

can u please tell me exactly where..?
No Rohan same result there is any alternative way for this ..?
Rohan I changed DocumentFiles[] to DocumentFiles2[] now its working.. great :-)
The problem is in your addElement function the line newId.innerHTML = "<input type='file' name='DocumentFiles2' class='multi' />"; should be like newId.innerHTML = "<input type='file' name='DocumentFiles[]' class='multi' />";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.