-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhotoGallary.html
101 lines (81 loc) · 2.82 KB
/
PhotoGallary.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PhotoGallary</title>
<style>
body {
background: #222;
margin-top: 20px;
font-family: Arial, Helvetica, sans-serif;
color: white;
}
.thumbnails {
margin-bottom: 50px;
}
.thumbnails img {
margin: 0 10px 10px 0px;
border: 4px solid white;
height: 120px;
}
.thumbnails img:hover {
border: 4px solid blue;
}
.preview img {
padding: 1px;
border: 2px solid blue;
width: 800px;
}
.upload{
padding-top: 22px;
}
</style>
</head>
<body>
<div id="container" align="center">
<h1>My PhotoGallary</h1>
<br />
<div class="thumbnails" id="imgPreview">
<img onmouseover="preview.src=img.src" name="img" src="" class="ipi" alt="imgPreview">
<img onmouseover="preview.src=img0.src" name="img0" src="" class="ipi" alt="imgPreview">
<img onmouseover="preview.src=img00.src" name="img00" src="" class="ipi" alt="imgPreview">
<img onmouseover="preview.src=img1.src" name="img1" src="imgs/img1.jpg" >
<img onmouseover="preview.src=img2.src" name="img2" src="imgs/img2.jpg">
<img onmouseover="preview.src=img3.src" name="img3" src="imgs/img3.jpg">
<img onmouseover="preview.src=img4.src" name="img4" src="imgs/img4.jpg">
</div>
<div class="preview" align="center">
<img name="preview" src="imgs/img1.jpg">
</div>
<div class="upload">
<p>Click on the "Choose File" button to upload a image:</p>
<form class="form" action="/action_page.php">
<input type="file" id="filename" name="filename">
<input type="submit">
</form>
</div>
</div>
<script>
const filename = document.getElementById("filename");
const previewContainer = document.getElementById("imgPreview");
const previewImage = previewContainer.querySelector(".ipi");
filename.addEventListener("change",function(){
// var i =0;
// for( i ;i<5;i++){
const file = this.files[0];
if(file){
const reader = new FileReader();
previewImage.style.display="block";
reader.addEventListener("load",function(){
console.log(this);
previewImage.setAttribute("src",this.result);
});
reader.readAsDataURL(file);
// }
}
})
</script>
</body>
</html>