-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·65 lines (43 loc) · 1.61 KB
/
index.php
File metadata and controls
executable file
·65 lines (43 loc) · 1.61 KB
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
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="dropzone.css" type="text/css" rel="stylesheet" />
<!-- 1 -->
<script src="jquery.min.js"></script>
<script src="dropzone.js"></script>
<script>
Dropzone.options.myDropzone = {
maxFilesize: 2000, //MB
clickable: true,
dictDefaultMessage: "Drag and Drop Image or File",
init: function() {
thisDropzone = this;
$.get('upload.php', function(data) {
$.each(data, function(key,value){
var ext = checkFileExt(value.name); // Get extension
var newimage = "";
// Check extension
if(ext != 'png' && ext != 'jpg' && ext != 'jpeg' && ext != 'gif'){
newimage = "./media/logo.jpg"; // default image path
} else { newimage = "./uploads/"+value.name };
var mockFile = { name: value.name, size: value.size, metadata: value.metadata };
thisDropzone.options.addedfile.call(thisDropzone, mockFile);
// thisDropzone.options.thumbnail.call(thisDropzone, mockFile, "./uploads/"+value.name);
thisDropzone.options.thumbnail.call(thisDropzone, mockFile, newimage);
thisDropzone.options.complete.call(thisDropzone, mockFile, value.metadata);
});
});
}
};
// Get file extension
function checkFileExt(filename){
filename = filename.toLowerCase();
return filename.split('.').pop();
}
</script>
</head>
<body>
<!-- 2 -->
<form action="upload.php" class="dropzone" id="my-dropzone"></form>
</body>
</html>