如何写文件上传下载
作者 huangxin
上传的代码
JSP
<div class="col-sm-6">
<input type="file" class="hidden" name="upload" id="upload1">
<input type="hidden" name="entity.meetingAttachId" value="${entity.meetingAttachId}">
<input type="text" name="entity.meetingAttach" value="${entity.meetingAttach}" placeholder="" class="form-control" readonly >
</div>
JS
var options1 = {
btnId: "btnUpLoad1",
fileId: "upload1",
successCall: function (data, status) {
$("[name='entity.meetingAttachId']").val(data.f_id);
$("[name='entity.meetingAttach']").val(data.fileName);
}
}
在$(function () {});
里面,添加
uploadFile(options1);
下载
jsp代码:
<a id="btn-download1" class="btn btn-sm btn-info down-load">下载</a>
js代码:
$(function () {
$("#btn-download1").click(function () {
download(fId1);
});
})