JS获取图片的缩略图
js获取上传文件的缩略图
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload Demo - AngularJS version</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.btn{ } .addfiles{
display: inline-block;
font-weight: 400;
text-align: center;
vertical-align: middle;
cursor:pointer;
background-image: none;
border:1px solid transparent;
white-space: nowrap;
padding:6px 12px;
font-size:14px;
line-height: 1.42857143;
border-radius: 4px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
margin-bottom:5px;
position: relative;
overflow: hidden;
color:#FFF;
background-color: #5CB85C;
border-collapse: #4CAE4C;
} .addfiles:hover, .addfiles:focus, .addfiles:active{
color:#FFF;
background-color: #47A447;
border-color:#398439;
text-decoration: none;
} .addfiles:active{
outline:0;
background-image: none;
-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);
box-shadow:inset 0 3px 5px rgba(0,0,0,.125);
} .addfiles input{
position: absolute;
top:0;
right:0;
margin:0;
opacity: 0;
-ms-filter:'alpha(opacity=0)';
font-size: 200px;
direction: ltr;
cursor:pointer;
display: block;
} </style>
<script>
function change(v){
getPath2(document.getElementById("img"),v,v.value);
}
//附带不用修改浏览器安全配置的javascript代码,兼容ie, firefox全系列
function getPath2(obj,fileQuery,transImg){
if(window.navigator.userAgent.indexOf("MSIE")>=1){
//obj.select();
//var path = document.selection.createRange().text;
//obj.removeAttribute("src");
//obj.setAttribute("src",path);
obj.setAttribute("src",transImg);
//obj.style.filter= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path+"', sizingMethod='scale');";
}else{
var file =fileQuery.files[0];
var reader = new FileReader();
reader.onload = function(e){
obj.setAttribute("src",e.target.result)
}
reader.readAsDataURL(file);
}
}
</script>
</head>
<body> <span class="btn addfiles">
<span>Add files...</span>
<input id="file" type="file" name="files[]" onchange="change(this)"/>
</span>
<div>
<img id="img" width="100px" height="100px" />
</div> </body>
</html>
JS获取图片的缩略图的更多相关文章
- JS获取图片的缩略图,并且动态的加载多张图片
找了好多资料也没有找到该死的ie的解决办法,最后放弃了ie <!DOCTYPE html> <html> <head> <meta charset=" ...
- JS获取图片实际宽高及根据图片大小进行自适应
JS获取图片实际宽高,以及根据图片大小进行自适应 <img src="http://xxx.jpg" id="imgs" onload="ad ...
- JS获取图片实际宽高
JS获取图片实际宽高,以及根据图片大小进行自适应 <img src="http://xxx.jpg" id="imgs" onload="ada ...
- js点击获取—通过JS获取图片的相对坐标位置
一.通过JS获取鼠标点击时图片的相对坐标位置 源代码如下所示: <!DOCTYPE html> <html lang="en"> <head> ...
- Js获取图片原始宽高
如果我们页面看到的图片都是缩略图,那就需要做个图片点击放大效果,那么怎样获取图片的原始宽高呢?方法如下: //获取图片原始宽度 function getNaturalWidthAndHeight(im ...
- Java乔晓松-android中获取图片的缩略图(解决OutOfMemoryError)内存溢出的Bug
由于android获取图片过大是会出现内存溢出的Bug 07-02 05:10:13.792: E/AndroidRuntime(6016): java.lang.OutOfMemoryError 解 ...
- js获取图片的EXIF,解决图片旋转问题
相信大家在做项目的时候会遇到在canvas里加入图片时,图片发生90°,180°的旋转.当时的你肯定时懵逼的,为毛. 其实这就是图片的EXIF搞的鬼. 什么是EXIF 简单来说,Exif 信息就是由数 ...
- js获取图片的原始尺寸
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- js点击获取—通过JS获取图片的绝对对坐标位置
一.通过JS获取鼠标点击时图片的相对坐标位置 源代码如下所示: <!DOCTYPE html> <html lang="en"> <head> ...
随机推荐
- malloc,free和new,delete之间的区别
1.malloc free 是c语言里面的,不过在c++中也能使用,这个只是申请的一块内存,一般不能申请对象的内存空间:2.new delete,是c++的,申请的也是一块内存,只是这个可以申请对象. ...
- 【iOS开发-55】图片轮播案例:scrollView的分页、滚动栏、利用代理控制定时器和Page Control以及多线程问题
案例: (1)用storyboard布局,这里用了三样东西. --UIScrollView就是我们准备存放滚动图片的容器. --Page Control就是控制页数的那几个小点点.能够设置有多少个点. ...
- ES,ZK,Mysql相关参数优化
1.ES 内存调优: vi config/jvm.options -Xms16g -Xmx16g 2.Zookeeper参数配置调优 2.1\在conf目录下 vi java.env export J ...
- CentOS 7.2通过yum安装zabbix
环境说明 系统版本 CentOS 7.2 x86_64 软件版本 yum安装zabbix 3.0.18 首先准备一台纯净的CentOS 7.2系统 1.配置zabbix源 [root@za ...
- javascript event loop
原文: https://blog.csdn.net/sjn0503/article/details/76087631 简单来讲,整体的js代码这个macrotask先执行,同步代码执行完后有micro ...
- 转:全面分析 Spring 的编程式事务管理及声明式事务管理
转:from: https://www.ibm.com/developerworks/cn/education/opensource/os-cn-spring-trans/
- navigationItem的设置和titleView的设置
设置导航栏中间的标题 self.navigationItem.title = @"title"; 设置导航栏的主题颜色 self.navigationBar.barTintColo ...
- Unity3D的三种坐标系
来自:http://blog.csdn.net/luxiaoyu_sdc/article/details/13168497 1, World Space(世界坐标): 我们在场景中添加物体(如:Cub ...
- HDU 5308 规律+模拟
给出N个数字N,要把全部数字用完.使用+-*/最后变为24.中间运算能够有有浮点数 对于1-14直接打表 15以上的能够通过13个同样数字得到24.然后使后面的数所有运算为0相加就可以 贴一发官方题解 ...
- red5截屏
在red5-web.xml添加 <bean id="rtmpSampleAccess" class="org.red5.server.stream.RtmpSamp ...