This works fine as a normal form:
<form id="frm1" enctype="multipart/form-data" action="form_handler_post.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
Send this file: <input name="userfile" type="file" />
<input type="text" name="theRefNum" />
<input type="submit" value="Send File" />
</form>
...but I want to post the contents of the form (i.e. the image) using jQuery, since I have lots of other data that I want to post at the same time and don't want to include it in the same form as the image upload. E.g.
$.post("form_handler_post.php", { name: "John", time: "2pm", otherData: "Friday", image:#######});
I've tried image:userfile
, image:'userfile'
and image:$('userfile').val()
but to no avail.
How do I include the image file in the data section - i.e. how do I access the image's value
?