body { margin:0; } .file { display:block; height:120px; width:120px; position:relative; margin:0 auto; overflow:hidden; text-decoration:none; text-indent:0; border:none; margin-top:20px; } .file input { height:120px; width:120px; font-size:100px; margin:0; padding:0; position:absolute; left:0; top:0; opacity:0; z-index:999; } .file img { width:120px; height:120px; position:absolute; left:0; top:0; border:none; } #img-box { text-align:center; width:100%; height:120px; margin:0; margin-top:20px; } #img-box img { width:120px; height:120px; margin-right:10px; border:1px solid #eee; }
uploadPreview({ fileID : "file", //input的id showID : "img-box",//预览图片存放的div盒子 maxLen : 2 //允许上传的最大值 });
用createObjectURL方法制作的可控制上传图片张数的预览插件!