<h3>HTML5 图片上传预览</h3> <input id="img" type="file" accept="image/*" /> <div id="photo"></div>
<script type="text/javascript"> $(function() { $('#img').change(function() { var file = this.files[0]; var r = new FileReader(); r.readAsDataURL(file); $(r).load(function() { $('#photo').html('<img src="' + this.result + '" alt="" />'); }) }) }) </script>