This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.html
79 lines (65 loc) · 1.87 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/adorn/adorn.css"/>
<script src="/adorn/adorn.js"></script>
<title>dropfile.js - Drop Files into Browser</title>
<style>
#holder{
border:1px solid lightgray;
min-height:100px;
font-size:20px;
color:gray;
text-align:center;
padding:20px;
}
#holder:hover{
background-color:lightgray;
}
#holder ul{
width:100%;
text-align:left;
}
#holder li img{
height:20px;
}
</style>
</head>
<body>
<h1>Drag and drop file demo</h1>
<div id="holder">
Drop files from desktop here
</div >
<h2>Source</h2>
<p>Include our drop file fix for IE8,9</p>
<script src="dropfile.js" class="pre"></script>
<p>Add event listeners to the area where we want to drop files</p>
<script>
if( !window.dropfile ){
document.getElementById("holder").innerHTML = "Ouch this browser doesn't support FileReader or the shim. " + (!Silverlight.isInstalled()?"<br/><b>Please install Silverlight</b>":"");
}
</script>
<script class="pre">
var holder = document.getElementById('holder');
holder.ondragover = function () { return false; };
holder.ondragenter = function () { return false; };
holder.ondrop = function (e) {
// ensure that we listen out for the window event
e = e || window.event;
// And that for the fix to work we accept `e.files`
var files = (e.files || e.dataTransfer.files);
var s = "";
for (var i = 0; i < files.length; i++) {
(function (i) {
var reader = new FileReader();
reader.onload = function (event) {
holder.innerHTML = "<li><img src='" + event.target.result + "' /> " + (files[i].name) + "</li>" + holder.innerHTML;
};
reader.readAsDataURL(files[i]);
})(i);
}
return false;
};
</script>
</body>
</html>