From e2edd6710144bc904874ab670e4b4b66e29ba831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B0=E5=B9=BF=E9=93=B6?= <273650669@qq.com> Date: Wed, 1 Nov 2017 18:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=AE=9A=E6=96=87=E4=BB=B6=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/client/client.js | 8 ++++++++ public/js/server/index.js | 8 ++++++++ routes/index.js | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/public/js/client/client.js b/public/js/client/client.js index 6805211..1835422 100644 --- a/public/js/client/client.js +++ b/public/js/client/client.js @@ -126,6 +126,14 @@ $(function(){ chunk_size: '4mb', // 分块上传时,每块的体积 auto_start: true, // 选择文件后自动上传,若关闭需要自己绑定事件触发上传 unique_names: true, + filters : { + max_file_size : '10mb', + prevent_duplicates: true, + // Specify what files to browse for + mime_types: [ + {title : "Image files", extensions : "jpg,gif,png,bmp"}, // 限定jpg,gif,png后缀上传 + ] + }, init: { 'FilesAdded': function(up, files) { plupload.each(files, function(file) { diff --git a/public/js/server/index.js b/public/js/server/index.js index f49360e..a2b8159 100644 --- a/public/js/server/index.js +++ b/public/js/server/index.js @@ -235,6 +235,14 @@ layui.use(['layer', 'form', 'jquery'], function () { chunk_size: '4mb', // 分块上传时,每块的体积 auto_start: true, // 选择文件后自动上传,若关闭需要自己绑定事件触发上传 unique_names: true, + filters : { + max_file_size : '10mb', + prevent_duplicates: true, + // Specify what files to browse for + mime_types: [ + {title : "Image files", extensions : "jpg,gif,png,bmp"}, // 限定jpg,gif,png后缀上传 + ] + }, init: { 'FilesAdded': function(up, files) { plupload.each(files, function(file) { diff --git a/routes/index.js b/routes/index.js index ccef424..72ebb54 100644 --- a/routes/index.js +++ b/routes/index.js @@ -27,7 +27,8 @@ router.get('/uptoken', function(req, res, next) { var mac = new qiniu.auth.digest.Mac(AppConfig.QINIU.accessKey, AppConfig.QINIU.secretKey); var options = { scope: 'kefu', - expires: 7200 + expires: 7200, + mimeLimit:"image/*" }; var putPolicy = new qiniu.rs.PutPolicy(options); var uploadToken=putPolicy.uploadToken(mac);