这可以作为正常形式正常工作:
<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>
...但我想使用 jQuery 发布表单的内容(即图像),因为我有很多其他数据要同时发布并且不想将其包含在与图片上传。例如
$.post("form_handler_post.php", { name: "John", time: "2pm", otherData: "Friday", image:#######});
我试过了image:userfile
,image:'userfile'
但image:$('userfile').val()
无济于事。
如何在数据部分包含图像文件 - 即如何访问图像value
?