So let’s say i have one input like this:
<input id="test" multiple="true" type="file" name="image_name[]" />
And now after i selected some fils i would like to “transfer” them to simple inputs
something like this
var offset = 0;
$.each($("#test")[0].files, function(i, file){
$("#my_form").prepend(
'<input type="file" name="image" value="'+$("#test")[0].item(offset).name+'" />'
)
offset++;
});
and then ofcourse i would submit them, now i know this code is very wrong, but i’m not so good with javascript so it’s just my guessing 🙂
For security reasons you cannot generate
input[type="file"]elements with a predefined value. And all jQuery gobbledygook will not help to make it happen because, contrary to common misconception, jQuery is built on the DOM API; jQuery is a wrapper around the DOM API (an awfully inefficient and error-prone one at that) and does not replace it.If one could do what you are trying to do, any Web site you visit could silently submit any file from your computer, provided that the cracker knew the file path or just guessed right. You do not want the browser vendors to let that happen.