Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //functions on change event of file input to select different file
- $('body').on('change', '#image_data', function(){
- if (this.files && this.files[0]) {
- abc += 1; //increementing global variable by 1
- var z = abc - 1;
- var x = $(this).parent().find('#previewimg' + z).remove();
- $(this).before("<div id='abcd"+ abc +"' class='abcd'><img id='previewimg" + abc + "' src=''/></div>");
- var reader = new FileReader();
- reader.onload = imageIsLoaded;
- reader.readAsDataURL(this.files[0]);
- }));
- }
- });
- //To preview image
- function imageIsLoaded(e) {
- $('#previewimg' + abc).attr('src', e.target.result);
- };
- success: function(data)
- {
- $("#previewimg" + abc).remove();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement