Commit 73cc45c8 authored by Mat's avatar Mat

affiche en preview l'image qu'on va uploader

parent 7310fc60
......@@ -18,6 +18,7 @@
</select><br>
<label for="file">Image</label>
<input type="file" name="file"><br>
<img id="preview" src="http://0.0.0.0:81/web/assets/img/biere/default.jpg" alt="image" width="100" height="100">
<button id="send">Envoyer</button>
</form>
......@@ -40,6 +41,19 @@ $(document).ready(function() {
}
);
// charge une preview pour l'image qu'on s'apprête à uploader
$('input[name=file]').change(function(e) {
if(this.files && this.files[0])
{
let reader = new FileReader();
reader.onload = function(e) {
$('#preview').attr('src', this.result)
};
reader.readAsDataURL(this.files[0])
}
});
// submit du formulaire, en POST (create)
$('#send').click(function(e) {
e.preventDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment