dropzone.js 拖拽上传文件

时间:2022-11-23 21:32:32

主要是记录一下dropzone.js 这个js基本用法

参考网址:http://www.dropzonejs.com/


1.所需js文件  (dropzone版本升级后可以不依赖jquery.js,但是写法大致相同)

  dropzone.js   jquery.js(可选)  dropzone.css(可选)

2.htm具体代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dropzone</title>
<link rel="stylesheet" type="text/css" href="dropzone.css" />
</head>

<body>

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="dropzone.js"></script>



<div id="dropz" width="100px" height="100px" class="dropzone"></div>
<script>
$("#dropz").dropzone({
url: "handle-upload.php",
addRemoveLinks: true,
dictRemoveLinks: "Remove File",
dictCancelUpload: "Cancel Upload",
maxFiles: 1,
maxFilesize: 5,
autoProcessQueue: true,
acceptedFiles: ".jpg,.png",
init: function() {
this.on("success", function(file) {
console.log("File " + file.name + "uploaded");
});
this.on("removedfile", function(file) {
console.log("File " + file.name + "removed");
});
}
});
</script>
</body>
</html>

3.实现例图

dropzone.js 拖拽上传文件

资源下载:http://download.csdn.net/detail/u013361445/9183539