How do I upload a file with Ajax? I have a file-type-input field but how do I send it as a parameter?
Code: Select all
<input type="file" /> //this is what I call a "file-type-input" field :D
With things like text-type-input elements I can just go ahead an send it's value as a parameter for my Ajax request.
Like this:
Code: Select all
$.post("file.php", {text: $("$textField").val()})
But how would I send file-type-input field's file as a parameter? Does the value of the file-type-input field what I want to send as a parameter? I need PHP to recognize this parameter as the $_FILES super global, as regular form posts do.
Please help me with this one I'd so much appreciate it.
EDIT: I googled for "Ajax file uploads" and found out that the XMLHttpRequest object doesn't support file uploads.
So then how do I upload files without refreshing? Looking for a real straight-forward tutorial please.
