I am using this script (from http://www.html5rocks.com/en/tutorials/file/dndfiles/):
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
// files is a FileList of File objects. List some properties.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
}
}
to loop through files dragged from desktop into an html element.
From that tutorial I can read the files and do something with the content.
I want something simpler.
I want a plain form:
<form method="post" enctype="multipart/form-data">
<input type="file" name="my_file" />
<input type="submit" />
</form>
and with javascript set the value of input[name="my_file"].
I can read from some pages that I can't set the value of a file input for security reasons. I do understand that I cannot set an arbitrary value of the file input but I don't understand why I can't set the value of the file input to be the file name of the drag'n'dropped file.
If I can read from the files I think I would also be able to post the files.
Are there any ways to accomplish what I want?
document.getElementById("input").oninput=function(){ /*submit form*/ }which fires whenever the selected input values changes.$form.submit()when it's done. So it should be done the other way around.