采取输入img类型选择的图片并加载到图像标签 [英] taking an input img type selected picture and load into an image tag

查看:241
本文介绍了采取输入img类型选择的图片并加载到图像标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个输入框做img文件上传。我想要做的是从数据(或选定的源),并路由到图像标签的src属性。

这样的事情:
http://jsfiddle.net/QC2c4/

这将是一个客户端验证者,以显示用户将要上传的东西。我知道我需要检查有效的img类型,.png,.bmp,.png,.tiff等的扩展名。



我会去链接过程?

解决方案

这是答案,作为一个额外的奖金我加载到预览窗格的图像给你的。关键是从文件选取器中取出文件[0] 对象。

http://jsfiddle.net/TbZzH/1/

So, i have an input box for doing a img file upload. What i was wanting to do is take the data from that (or the selected source) and route that into the src attribute of an image tag.

something like this: http://jsfiddle.net/QC2c4/

It is sort of going to be a client side verifier to show what the user is going to upload. I know that i am going to need to check the extension for the valid img types, .png, .bmp, .png, .tiff, etc, etc.

How would i go about the linking process?

解决方案

Here's the answer, and as an added bonus I loaded the image into the preview pane for ya. The key is pulling the files[0] object from the file picker on change.

http://jsfiddle.net/TbZzH/1/

这篇关于采取输入img类型选择的图片并加载到图像标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆