Created
September 9, 2017 09:16
-
-
Save Sanix-Darker/436319afcd32638caad72f5a5e38d309 to your computer and use it in GitHub Desktop.
Preview Image
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
<img id="blah" src="#" alt="Image du blog" style="width: 30%;" /> | |
<input type="file" id="imgInp" name="img" required="required" class="form-control col-md-9 col-xs-12" required="" /> | |
<script | |
src="https://code.jquery.com/jquery-2.2.4.min.js" | |
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" | |
crossorigin="anonymous"></script> | |
<script> | |
function readURL(input,cible) { | |
if (input.files && input.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
$('#'+cible).attr('src', e.target.result); | |
} | |
reader.readAsDataURL(input.files[0]); | |
} | |
} | |
$("#imgInp").change(function(){ | |
readURL(this,'blah'); | |
}); | |
$('#blah').click(function(){ | |
$("#imgInp").trigger('click'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment