在选择文件之后显示图片,然后再上传 [英] displaying image after Choose File, before upload
本文介绍了在选择文件之后显示图片,然后再上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选择图像后并在上传之前(在数据库中插入之前)如何显示图像?
此代码不显示图像:
how can after choose image and before upload (before insert in database) displaying image?
this code not displaying image:
var a = $('<img src="' + g.STRING.selected.replace('$file', v) + '" alt="Angry face" width="50" height="50" />'),
<input type="file" name="image' >
尊重
推荐答案
您可以使用HTML5 File API(教程)以显示所选文件.最好的方法可能是使用FileReader
获取文件的dataURL并将其分配给img
的src
.
You can use the HTML5 File API (tutorial) to display the selected file. The best way is probably to use a FileReader
to get a dataURL of the file and assign it to a src
of an img
.
这篇关于在选择文件之后显示图片,然后再上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文