javascript - Reset button for each preview image -
i don't want create remove button; each images previewed before going uploaded. reason because each image has unique id, if uses remove button mess id arrangement when 1 of images removed.
i know little complicated.
how create reset button each images? so, when user click reset button, open window of user computer pick new image, , id of new picked image still same before.
here code:
var ftype = new array(), count1 = 0; $("#imginput").change(function () { readurl(this); }); function readurl(input) { var files = input.files; var output = document.getelementbyid("result"); (var = 0; < files.length; i++) { var file = files[i]; var picreader = new filereader(); var divid = 'div_' + i; var spanid = 'span_' + i; var count = 0; picreader.addeventlistener("load", function (event) { var picfile = event.target; var picnames = files[count].name; var mimetypes = picfile.result.split(','); var mimetype1 = mimetypes[0]; var mimetype = mimetype1.split(':')[1].split(';')[0]; count++; count1++; var div = document.createelement("div"); div.setattribute('id', 'div_' + count); div.setattribute('class', 'divclass'); if (mimetype.match('image')) { div.innerhtml = "<img id='img_" + count1 + "' class='thumbnail' src='" + picfile.result + "'" + "title='" + picnames + "' width='96' height='80' alt='item image' style='position:relative;padding:10px 10px 10px 10px;' data-valu='" + mimetype + "'/>"; } output.insertbefore(div, null); }); picreader.readasdataurl(file); } }
Comments
Post a Comment