日期:2014-05-17 浏览次数:20784 次
//文件上传前的验证
function check(){
var file=document.getElementById("myFile").value;
var wid=document.getElementById("workflowId").value;
var arr=new Array();
arr=file.split('\\');
var name=arr[arr.length-1];
if(file==""){
top.Dialog.alert("请选择需要上传的文件!");
return false;
}else{
var okk=false;
$.ajax({
type:"post",
async:false,
url:"yanZhengWenDang.action?dt="+new Date().getTime(),
data:{"wjm":name,"wid":wid},
success:function(data){
if(data.ok){
//判断是否要替换
top.Dialog.confirm("该文件名已经存在,是否要替换?",function funcOK(){
okk=true;},function funcCal(){okk=false;});
}else{
okk=true;
}
},
dataType:"json"
});
return okk;
}
}
<!-- 表单上传文件! -->
<s:if test="ok">
<div id="uf" style="text-align: center;">
<form action="uploadworkflowfile.action"enctype="multipart/form-data" method="post" onsubmit="return check()">
<font style="font-weight: bold;"> 文件上传: </font>
<input type="hidden" id="workflowId" value="${workflow.id }" name="workflowId"/>
<input type="file" id="myFile" name="myFile"/>
<input type="submit" value="上传"/>
</form>
</div>
</s:if>