1.jsp
<span class="w">商业计划书</span>
<label style="cursor: pointer; color: #fff; margin-left: 121px; margin-top: 32px" class="btn btn-success">
<span style="font-size: 16px;">点击上传</span>
<input id="fileurl" name="fileurl" htmlEscape="false" type="hidden" value="${infoProject.fileurl}"/>
<input size="2" type="file" hidden="hidden" id="uploadfile2" name="uploadfile2" onchange="ajaxFileUpload2()" style="display: none" />
</label>
function ajaxFileUpload2() {
var uploadUrl = encodeURI(encodeURI("${contextPath}/commons/uploadfile"));
$.ajaxFileUpload({
url : uploadUrl,
secureuri : false,
fileElementId : 'uploadfile2',
dataType : 'text',
success : function(data, status) {
var dataset = jQuery.parseJSON(jQuery(data).text());
if (dataset.ret == "ok") {
$("#fileurl").val(dataset.url);
showmsg(0, '文件上传成功');
} else if (dataset.ret == "empty") {
showmsg(0, '没有选择文件,请先选择文件!');
} else {
shomsg(0, '文件上传失败,请重试!!');
}
},
error : function(data, status, e) {
showmsg(0, '文件上传失败,请重试!!');
}
});
}