Created
April 14, 2015 06:01
-
-
Save jokosusilo/79cb080ba59a1c449ab3 to your computer and use it in GitHub Desktop.
Preview image setelah memilih file gambar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- Based on HTML5 Bones | http://html5bones.com --> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Page Title</title> | |
<meta name="description" content=""> | |
<!-- Mobile-friendly viewport --> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- Style sheet link --> | |
<style> | |
::-webkit-scrollbar-track{ | |
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.2); | |
background-color: #F5F5F5; | |
} | |
::-webkit-scrollbar{ | |
width: 6px; | |
background-color: #F5F5F5; | |
} | |
::-webkit-scrollbar-thumb{ | |
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.2); | |
background-color: #555; | |
} | |
</style> | |
</head> | |
<body> | |
<form id="form1"> | |
<input type='file' id="imgInp" /> | |
<br> | |
<img id="blah" src="http://allaccessmoving.com/wp-content/themes/thunder1/skins/images/preview.png" alt="your image" height="100"/> | |
</form> | |
</body> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script> | |
function readURL(input) { | |
if (input.files && input.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
$('#blah').attr('src', e.target.result); | |
} | |
reader.readAsDataURL(input.files[0]); | |
} | |
} | |
$("#imgInp").change(function(){ | |
readURL(this); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment