| 上传图片直接预览
					当前位置:点晴教程→知识管理交流
					
					→『 技术文档交流 』
					
				 
 html代码 <div id="rrr"></div> <input type="file" id="hiddenfile" name="image" onchange="getimgload()"/> js代码 function getimgload(){     var file=document.getElementById("hiddenfile").files[0];     var reader=new FileReader();     reader.onload = function ( event ) {       var htmlStr = null;       var src = null;       if(!/image\/\w+/.test(file.type)){         alert("文件必须为图片!");         return false;       }         src = event.target.result;         htmlStr = "<img
style='width:50px;height:50px' src='"+src+"'>";       $("#rrr").html("");       $("#rrr").append(htmlStr);     };     reader.readAsDataURL(file);   } 复制直接使用 该文章在 2021/1/29 10:07:17 编辑过 | 关键字查询 相关文章 正在查询... |