开发者

How to fake ajax file upload?

I've an upload form I would like to populate with a file, in particular an image.

My understanding is that I need to create a File object to put in the FileList of the relative form. Currently the image I have is in the data URI format "data:image/png;base64,..." but I can change that.

If that is true how do I create the corre开发者_运维知识库ct File object from an image and add it to the FileList? If it is not do you suggest a better solution?


Use a regular form and target it to an iframe with display set as none.

<form id="my_form" enctype="multipart/form-data" action="upload_handler.php" method="POST" target="upload_target">
   <input name="uploadfile" type="file" />
   <input type="submit" value="Upload File" />
</form>
<iframe id="upload_target" name="upload_target" style="display:none;"></iframe> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜