From ff3067f233e1e5008ce5981758f4c79fd3cd90dc Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 20 Feb 2019 13:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/files_api.py | 25 +++++++++++++++++++++++++ route/static/app/files.js | 16 ++++++++-------- route/static/app/upload.js | 24 +++++++++++------------- route/static/css/site.css | 4 ++-- 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/class/core/files_api.py b/class/core/files_api.py index 9bf635145..2a9585e74 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -164,6 +164,31 @@ done os.system('/etc/init.d/mw start') return public.returnJson(True, '任务已删除!') + # 上传文件 + def uploadFileApi(self): + from werkzeug.utils import secure_filename + from flask import request + + path = request.args.get('path', '').encode('utf-8') + + if not os.path.exists(path): + os.makedirs(path) + f = request.files['zunfile'] + filename = os.path.join(path, f.filename) + if sys.version_info[0] == 2: + filename = filename.encode('utf-8') + s_path = path + if os.path.exists(filename): + s_path = filename + p_stat = os.stat(s_path) + f.save(filename) + os.chown(filename, p_stat.st_uid, p_stat.st_gid) + os.chmod(filename, p_stat.st_mode) + + msg = public.getInfo('上传文件[{1}] 到 [{2}]成功!', (filename, path)) + public.writeLog('文件管理', msg) + return public.returnMsg(True, '上传成功!') + def getRecycleBinApi(self): rPath = self.rPath if not os.path.exists(rPath): diff --git a/route/static/app/files.js b/route/static/app/files.js index 5fa2e7cb8..dd5171a26 100755 --- a/route/static/app/files.js +++ b/route/static/app/files.js @@ -1262,31 +1262,31 @@ function getFileBytes(fileName, fileSize){ //上传文件 -function UploadFiles(){ +function uploadFiles(){ var path = $("#DirPathPlace input").val()+"/"; layer.open({ type:1, closeBtn: 2, title:lan.files.up_title, - area: ['500px','500px'], + area: ['500px','300px'], shadeClose:false, content:'
\ \ - \ - \ + \ + \ \ \ - '+lan.files.up_coding+':\ + 文件编码:\ \ \ - \ + \
' }); - UploadStart(); + uploadStart(); } //设置权限 diff --git a/route/static/app/upload.js b/route/static/app/upload.js index 639785845..09f881be4 100755 --- a/route/static/app/upload.js +++ b/route/static/app/upload.js @@ -50,7 +50,7 @@ MyAjax.prototype.handle = function(d, f) { i.send(g[0]), j.async === !1 && l.handle(i, j) }; -function UploadStart(d) { +function uploadStart(d) { var a = function(e) { this.uptype = e.UpType; this.url = e.url; @@ -99,7 +99,7 @@ function UploadStart(d) { if(e.size <= 0) { this.up_box.insertAdjacentHTML("beforeEnd", "
  • " + e.name + ""+lan.upload.file_err_empty+"
  • ") } else { - this.up_box.insertAdjacentHTML("beforeEnd", "
  • " + e.name + "" + (ToSize(e.size)) + ""+lan.upload.up_sleep+"
  • "); + this.up_box.insertAdjacentHTML("beforeEnd", "
  • " + e.name + "" + (toSize(e.size)) + ""+lan.upload.up_sleep+"
  • "); this.FilesArray.push([e, (this.filesalllength - 1 < 0 ? 0 : this.filesalllength) + j]) } } @@ -179,17 +179,17 @@ function UploadStart(d) { progress: function(j) { h.FileProgress = Math.floor(j.loaded / j.total * 100) + "%"; if(h.FileProgress == "100%") { - h.FileProgress = lan.upload.up_save + h.FileProgress = '正在保存..'; } - h.SetTxt(i[e][1], lan.upload.up_speed + h.FileProgress, "#005100") + h.SetTxt(i[e][1], '上传进度:' + h.FileProgress, "#005100") }, success: function(j) { h.str.serverdata = false; - h.SetTxt(i[e][1], lan.upload.up_ok, "#005100"); + h.SetTxt(i[e][1], '已上传成功', "#005100"); h.ready(i, e + 1, g); h.num++; if(i.length > 1) { - var k = (h.num == i.length) ? lan.upload.up_ok_1 : lan.upload.up_ok_2; + var k = (h.num == i.length) ? '上传完成': '已上传'; $("#totalProgress").html("

    " + k + h.num + "/" + i.length + "

    ") } if(h.num == i.length) { @@ -199,7 +199,7 @@ function UploadStart(d) { h.num = 0 } if(!d) { - GetFiles(getCookie("Path")) + getFiles(getCookie("open_dir_path")); } }, error: function(j) { @@ -216,23 +216,21 @@ function UploadStart(d) { UpType: new Array(), FilesSize: 5242880000, MaxUpNum: 100, - url: "/files?action=UploadFile&path=" + document.getElementById("input-val").value + url: "/files/upload_file?path=" + encodeURIComponent(document.getElementById("input-val").value) }); c.opt.addEventListener("click", function() { c.file_input.click() }, false); c.up.addEventListener("click", function() { - c.read() + c.read(); }, false); c.file_input.addEventListener("change", function() { - c.SelectFile() + c.SelectFile(); }, false) } catch(b) { c.opt.disabled = true; c.up.disabled = true; c.file_input.disabled = true; - layer.msg(lan.upload.ie_err, { - icon: 5 - }) + layer.msg('抱歉,IE 6/7/8 不支持请更换浏览器再上传', {icon: 5}); } }; \ No newline at end of file diff --git a/route/static/css/site.css b/route/static/css/site.css index 20c12694f..5383bd3c2 100755 --- a/route/static/css/site.css +++ b/route/static/css/site.css @@ -3452,8 +3452,8 @@ html .menu .menu_exit:hover { margin: 0; padding: 10px; clear: both; - height: 360px; - overflow: auto + height: 160px; + overflow: auto; } #up_box li {