I'm not even sure if this is possible...
Given a form with <input id="fileinput" type="file" />
, and a valid selected file, can I POST the value
using document.getElementById("fileinput").value
in an XMLHttpRequest
object and expect $_FILES
to hold the object? If the POST can be reasonably expected to go through, how can I get the file's info?
Follow Up
Is it then possible to use a standard XMLHttpRequest
Object with FileReader
for uploading a file? Or is this an entirely different can of fish? I'm trying to minimize extraneous code, not repeatedly ask stupid questions.
Edit - Closing
Found out it can be done with no issue and few problems using just the rudimentary file API without filereader, though it incorporates filereader for those who have it.
Essentially, use XMLHttpRequest().upload
to send the File
. Completely asynchronous; but no joy in IE or Opera, in which case I can fall back to a standard synchronous form or to the iframe fake.
Anyhow, since apparently it can't be done, I think it'll make a great piece of open source to publish. Thanks all.