Authored by zhangtianqi

禅道:漏洞上传文件

... ... @@ -128,6 +128,9 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
</div>
<div><input type="hidden" id="vulnerabilitiesId" name="vulnerabilitiesId" value="${d.id}"></div>
</div>
<div class="layui-form-item">
<button type="button" class="download">下载附件</button>
</div>
</form>
`
//漏洞处理抽屉
... ... @@ -143,6 +146,50 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
move: false,
success:()=>{
form.render();
if(d.filePath){
let docMime = d.fileName.slice(d.fileName.lastIndexOf('.') + 1); // 获取文件的后缀
console.log(docMime,"-------");
// 判断下载的文件类型
let mineType = "";
switch (docMime) {
case "xls":
mineType = "application/vnd.ms-excel";
break;
case "xlsx":
mineType = "application/vnd.ms-excel";
break;
case "docx":
mineType = "application/msword";
break;
case "doc":
mineType = "application/msword";
break;
case "zip":
mineType = "application/zip";
break;
case "html":
mineType = "text/html";
break;
case "markdown":
mineType = "text/markdown";
break;
default:
break;
}
let url = window.URL.createObjectURL(new Blob([d.filePath], { type: mineType }));
console.log(url);
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", d.fileName);
document.body.appendChild(link);
link.click();
// 销毁超连接
window.URL.revokeObjectURL(url);
}else{
layer.msg("无附件信息", {offset: '15px', icon: 7, time: 1000});
}
},
yes:(index)=>{
var formData = form.val('vulnerabilityForm');
... ...
... ... @@ -118,7 +118,6 @@
ref="upload"
action="#"
style="display: inline"
:auto-upload="false"
:limit="1"
:on-exceed="handleExceed"
:auto-upload="false"
... ...
... ... @@ -263,7 +263,7 @@ export default {
default:
break;
}
let url = window.URL.createObjectURL(new Blob([row.filePath], { type: "application/msword" }));
let url = window.URL.createObjectURL(new Blob([row.filePath], { type: mineType }));
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
... ...