Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Ids = 1;
- function tambah_data(){
- var html ='<div id="file_div_'+Ids+'" >';
- html+='<div class="row"><div class="col-md-2">';
- html+=' <input type="text" placeholder="Nama File" class="form-control" name="nama_file[]">';
- html+='</div>';
- html+='<div class="col-md-2">';
- html+=' <input type="file" name="file[]" onChange="readImage(this,'+Ids+')">';
- html+='</div>';
- html+='<div class="col-md-2">';
- html+=' <button onClick="removeFile(\''+Ids+'\');" type="button" class="btn btn-danger">X</button>';
- html+='</div></div>';
- html+='<div class="row">';
- html+='<div class="col-md-5">';
- html+='<br/><img style="width:150px;height:150px" id="img_'+Ids+'">';
- html+='</div>';
- html+='</div>';
- html+='<br/></div>';
- $("#gen_data").append(html);
- Ids++;
- }
- function removeFile(Ids){
- $('#file_div_'+Ids).remove();
- }
- function readImage(input,ids){
- if (input.files && input.files[0])
- {
- var reader = new FileReader();
- reader.onload = function (e) {
- $('#img_'+ids).attr('src', e.target.result);
- }
- reader.readAsDataURL(input.files[0]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement