"Select Multiple File attachments and show it in the list"
Bootstrap 4.1.1 Snippet by Ranjith Ramesh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!-- self sevice application starts -->
<div class="drag-upload-file">
<div class="container">
<div class="row">
<div class="col-sm-5">
<h3>Attachments</h3>
</div>
<div class="col-sm-7">
<div class="file-upload">
<div class="fields-details">
<input type="file" multiple id="myFile" name="img" onChange="myFunction()"/>
<h4><i class="fa fa-file"></i><span>Drop file here or click to upload</span></h4>
</div>
</div>
<div class="attachements">
<div class="items">
<div class="details" id="list">
<a href=""><i class="fa fa-close"></i></a>
</div>
</div>
<!-- items ends -->
</div>
</div>
</div>
</div>
</div>
<!-- self sevice application ends -->
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* drag-upload-file starts */
.drag-upload-file{
width:100%;
float:left;
padding: 60px 0;
background: #fff;
}
.drag-upload-file h4{
border:0px;
}
.drag-upload-file h3{
text-align: right;
}
.drag-upload-file .file-upload{
width:100%;
float:left;
}
.drag-upload-file .fields-details{
border: 1px solid #cacaca;
border-radius: 8px;
background: #fbfbfb;
text-align: center;
position: relative;
}
.drag-upload-file .fields-details input[type="file"]{
width: 100%;
height: 76px;
background: #fbfbfb;
opacity: 0;
text-align: center;
z-index: 999;
}
.drag-upload-file .fields-details h4{
border: 0px;
width: auto;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
const arr = [];
function myFunction() {
var x = document.getElementById("myFile").files;
arr.push(x[0]);
var convertList = [];
for(var i= 0; i< arr.length; i++){
console.log(arr[i].name)
convertList.push("<div>" + arr[i].name + "</div>");
}
document.getElementById("list").innerHTML = convertList.join("")
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: