When I add a picture in the browser, I want to display it immediately, and then upload it to the server. Ie the user chose a photo to add in the dialog box and immediately display the contents
How to do this?
thank
1 answer
$('input[type="file"]').change(function () { var file = this.files; //Files[0] = 1st file if (file[0]) { var reader = new FileReader(); reader.readAsDataURL(file[0], 'UTF-8'); reader.onload = function (event) { var result = event.target.result; $('.preview').attr('src', event.target.result); //Img с классом preview }; } }) |