我有一个上传的形式,我想填充的文件,尤其是图像。
I've an upload form I would like to populate with a file, in particular an image.
我的理解是,我需要创建一个文件对象放置在相对格式的文件列表。目前,像我是在数据URI格式。数据:图像/ PNG; BASE64,...但我可以改变
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 correct File object from an image and add it to the FileList? If it is not do you suggest a better solution?
使用常规的形式和目标到一个iframe与显示器设置为none。
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>