1、获取文件的方法
file对象是来自用户在一个<input>表单元素上选择文件后返回的filelist对象,也可以是来自自由拖拽操作生成的dataTransfer对象,dataTransfer是拖拽事件对象的属性。
2、示例代码
<body>
<div id="touxiang"></div>
<div id="drag"></div>
</body>
<style type="text/css">
#touxiang{
width:200px;
height:200px;
line-height:200px;
text-align:center;
font-size:80px;
border:1px solid #ccc;
margin:0 auto;
position: relative;
}
#touxiang:after{
content:"+";
color:#ccc;
}
#drag{
width:500px;
height:350px;
border:1px dashed #ccc;
margin:0px auto;
}
#touxiang img{
width:200px;
height:200px;
position: absolute;
top:0;
left:0;
z-index:1;
}
<script type="text/javas