1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<!DOCTYPE html> <html> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> <script > $(window).load(function(){ function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); $('#blah').show(); reader.onload = function (e) { $('#blah').attr('src', e.target.result); }; reader.readAsDataURL(input.files[0]); $("#imgInp").hide(); } } $("#imgInp").change(function(){ readURL(this); }); }); </script> <style> #blah { height: 200px; display: none; } </style> <form enctype="multipart/form-data" id="form1" method="post" action="saveupload.php" > <input name="userfile" type="file" id="imgInp" /> <img id="blah" src="#" /> <input type="submit" name="name" class="name" value="Submit" /> </form> </html> |
