在将图像上载到服务器之前显示图像预览 [英] Show the image preview before uploading it to the server
问题描述
您好,我正在寻找一种基于Javascript或jQuery的解决方案,以显示SELECTED图像而非上载图像的图像预览. 因此,一旦用户选择了图像,便会显示该图像的预览. 我没有任何代码,我在这里很迷路. 我需要基于HTML + Javascript或jQuery的解决方案. 如果需要,我还可以使用一些PHP
Hello I am looking for a Javascript or jQuery based solution to show an image preview of the SELECTED image and not of the uploaded one. So as soon as the user selects the image a preview will be shown of this image. I do not have any code, I am pretty lost here. I need a solution HTML + Javascript or jQuery based. I can also use some PHP if necessary
推荐答案
为此,您需要使用 HTML5文件API .除了IE9,几乎所有最新的浏览器都支持此功能. Safari 5.1支持此功能,但仍处于测试阶段.您可以在此处检查HTML5 File API浏览器的兼容性.
To do that, you need to use the HTML5 File API. Almost every latest browsers support this feature except IE9. Safari 5.1 supports this but it's still in beta. You can check the HTML5 File API browser compatibility here.
关于使用HTML5 File API显示预览的很好的教程,例如此.
There are good tutorials about using the HTML5 File API to display preview like this or this.
If you need more, you can find more with googling. You may need to use Progressive enhacement.
这篇关于在将图像上载到服务器之前显示图像预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!