I want to get a file (image or video) from an
<input type='file' id='file_i'/>
// Not this <input type='submit'/>
Using an XMLHttpRequest
like this
function img() {
var fd = new FormData();
fd.append('file', document.getElementById("file_i").files[0]);
var req;
if (window.ActiveXObject) {
req=new ActiveXObject();
} else {
req=new XMLHttpRequest();
}
req.open("post", "Image", true);
req.send(fd);
}
for example.
Then in the servlet doing this:
new FileInputStream(new File(request.getParameter("file")))
How can I retrieve that file? Thanks in advance.