读取input:file的路径并显示本地图片的方法
来源:互联网 发布:个人博客数据库 编辑:程序博客网 时间:2024/06/07 09:12
<!doctype html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> <title>Image preview example</title> <script type="text/javascript"> var loadImageFile = (function () { if (window.FileReader) { var oPreviewImg = null, oFReader = new window.FileReader(), rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i; oFReader.onload = function (oFREvent) { if (!oPreviewImg) { var newPreview = document.getElementById("imagePreview"); oPreviewImg = new Image(); oPreviewImg.style.width = (newPreview.offsetWidth).toString() + "px"; oPreviewImg.style.height = (newPreview.offsetHeight).toString() + "px"; newPreview.appendChild(oPreviewImg); } oPreviewImg.src = oFREvent.target.result; }; return function () { var aFiles = document.getElementById("imageInput").files; if (aFiles.length === 0) { return; } if (!rFilter.test(aFiles[0].type)) { alert("You must select a valid image file!"); return; } oFReader.readAsDataURL(aFiles[0]); } } if (navigator.appName === "Microsoft Internet Explorer") { return function () { alert(document.getElementById("imageInput").value); document.getElementById("imagePreview").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = document.getElementById("imageInput").value; } } })(); </script> <style type="text/css"> #imagePreview { width: 160px; height: 120px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale); } </style> </head> <body> <div id="imagePreview"> </div> <form name="uploadForm"> <p> <input id="imageInput" type="file" name="myPhoto" onchange="loadImageFile();" /><br /> <input type="submit" value="Send" /></p> </form> </body> </html>
1 0
- 读取input:file的路径并显示本地的图片
- 读取input:file的路径并显示本地图片的方法
- 读取input:file的路径并显示本地图片的方法
- 读取input:file的路径并显示本地图片的方法
- 【javascript】File API 读取并显示本地图片 -1
- 从指定的路径中读取图片,并显示出来
- 读取input file路径预览图片
- 如何显示选择input file的图片
- 使用input file 上传图片并显示
- input file本地图片预览的方法(兼容IE、Chrome和Firefox)
- 通过<input type='file'>本地回显图片的方法
- 将图片存入sqlserver中并读取显示的方法
- python 读取并显示图片的两种方法
- python 读取并显示图片的两种方法
- python 读取并显示图片的两种方法
- python 读取并显示图片的两种方法
- python 读取并显示图片的两种方法
- Python读取并显示图片的两种方法
- hdu 1009 FatMouse' Trade (水题,贪心)
- hdu 4864 Task 贪心
- windows 如何查看端口占用情况
- 营销软件下载详情咨询
- MyEclipse2014安装SDK
- 读取input:file的路径并显示本地图片的方法
- 在ubuntu上安装maven
- iOS 中捕获程序崩溃日志
- 八皇后
- poj 1861 Network(图论:最小生成树)
- Ext.util.TaskRunner 执行一次
- 【Leetcode长征系列】Pascal's Triangle II
- android 两个 activity 用 handler传递数据
- 矩阵快速幂 斐波那契数列