67,513
社区成员
发帖
与我相关
我的任务
分享
<!-- jquery 文件上传插件 -->
<link href="css/default/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/default/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/default/swfobject.js"></script>
<script type="text/javascript" src="js/default/jquery.uploadify.v2.1.0.js"></script>
<!-- end -->
<script type="text/javascript">
//后台需要的一些列参数
function fileUpload(){
$('#file1').uploadifySettings('scriptData',
{
'bidDocumentType':'1',
'bidFile.tenderid': '${tender.id}',
'bidFile.projectid':'${tender.projectid}',
'bid.companyid':'${bid.companyid}',
'bid.addr':'${bid.addr}',
'bid.taxno':'${bid.taxno}',
'bid.businessentity':'${bid.businessentity}',
'bid.contactname':'${bid.contactname}',
'bid.fax':'${bid.fax}',
'bid.tel':'${bid.tel}',
'bid.email':'${bid.email}',
'tender.id':'${tender.id}',
'tender.projectid':'${tender.projectid}'
});
$('#file1').uploadifyUpload(); //jQuery('#file1').uploadifyUpload()
}
$(document).ready(function() {
$("#file1").uploadify({
'uploader' : 'swf/uploadify.swf',
'script' : 'bidUploadOrDown_uploadBidDocument.action',
'cancelImg' : 'images/jqueryUpload/cancel.png',
// 'folder' : 'uploads',
'fileDataName' :'file',
'sizeLimit' : 1024*1024*100,
'auto' : false,
'multi' : false,
'simUploadLimit' : 2,
'fileDesc':'请选择rar,doc,pdf,txt文件',
'fileExt':'*.doc;*.pdf;*.rar;*.txt',
'height' : 24,
'width' : 180,
'buttonImg' : 'images/jqueryUpload/picture.jpg',
'wmode' : 'transparent',
onSelect : function (event, queueID,fileObj){
if(fileObj.size>1024*1024*100){
alert("文件大小不能超出100MB!");
}
},
onComplete : function (event, queueID, fileObj, response, data){
alert("文件上传成功!");
//上传成功后刷新一下文件列表
$("#divID").load("bidUploadOrDown_getUpSuccessFileName.action",{"tender.id":${tender.id},"random":Math.random()});
},
onError : function(event, queueID, fileObj){
alert("文件上传失败!");
}
});
});
</script>
</head>
<body>
<table>
<tr>
<td>
技术标:
<input type="file" name="file" id="file1" value=""/>
<a href="javascript:void(0)" onclick="fileUpload()">上传</a> </td>
</tr>
</table>
<div id="divID">
<c:if test="${not empty requestScope.bidFielList}">
<c:forEach items="${requestScope.bidFielList}" var="bidFile">
<span style="color: olive;">
${bidFile.filename}
<a href="javaScript:void(0)" onclick="dleteBidFile(${tender.id},${tender.projectid}, '${bidFile.filename}')">删除文件</a>
</span>
</br>
</c:forEach>
</c:if>
</div>
<div>
上传完成后可点击<a href="bidUploadOrDown_previewBidDocument.action?tender.id=${tender.id}&tender.projectid=${tender.projectid}">下一步</a>进行确认
</div>
</div>
</body>
</html>
public String uploadBidDocument() throws IOException {
String bidDocumentType = super.getRequest().getParameter(
"bidDocumentType");
// 上传文件
if (file != null) {
try {
fileFileName = bidFileServiceImpl.transformFileName(
bidDocumentType, fileFileName, sysUser);
bidFile.setUserid(sysUser.getId());
bidFile.setCompanyid(sysUser.getCompanyid());
bidFile.setFilename(fileFileName);
bid.setTenderid(bidFile.getTenderid());
bid.setProjectid(bidFile.getProjectid());
bid.setBidtime(new Date());
bid.setUserid(sysUser.getId());
String filePatch = bidFileServiceImpl.uploadBidDocument(
bidFile, bid, file, fileFileName);
if (Commons.NOT_ALLOW_UPLOAD_AGAIN.equals(filePatch)) {
//如果是上传相同的一个文件吗,提示不能重复上传
setAttribute("uploadMessage",getText("InviteBid.NOT_ALLOW_UPLOAD_AGAIN"));
} else {
setAttribute("uploadMessage",
getText("InviteBid.UPLOAD_SUCCESS"));
setAttribute("isAppSpan", "true");
setAttribute("filePath", filePatch);
}
}
} catch (Exception e) {
// 可记录日志
e.printStackTrace();
setAttribute("uploadMessage", getText("InviteBid.UPLOAD_FAIL"));
}
} else {
//请选择一个要上传的文件
setAttribute("uploadMessage",
getText("InviteBid.PLEASE_SELECT_UPLOAD_FILE"));
}
setAttribute("bidDocumentType", bidDocumentType);
return "uploadIframe";
}