IE提交表单的input文件上传 上传之后怎么清空该input的数据

codingjava 发布于 2015/11/24 11:39
阅读 2K+
收藏 0

发现这个清空input的方法,在IE浏览器下不支持,其他浏览器就可以,由于不可以通过清空form的方法处理,好多网上的方案都实现不了,因为form还有其他数据的,不可以把整个form清空.

我的实现是这样的$("#branchIdImage").val("");  //清空缓存

不过发现出现浏览器支持的问题


代码是这样的

<!-- 用户添加和修改信息共用面板 start background-color: #F0F8FF;-->
<div id="addEmployeeDlg"  class="easyui-dialog" closed="true" style="width:720px;height:430px;overflow:auto;margin:6px;top:2px;">  
<form id="empDetailForm"  method="POST">
<table>
<tr>
<td>
<span style="color:red;font-size: 12px;">*</span>
<span class="fieldTitle" style="font-size: 13px;">登&nbsp;&nbsp;&nbsp;录&nbsp;&nbsp;&nbsp;名:</span>
</td>
<td>
<input id="id" name="webObj.userId"  maxlength="20" readonly="readonly"/><!-- 用户帐号 -->
<input id="employee" name="webObj.employee" type="hidden" ><!-- 隐藏用户身份唯一标识 -->
</td>
<td>
<span style="color:red;font-size: 12px;">*</span>
<span class="fieldTitle" style="font-size: 13px;">&nbsp;&nbsp;姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</span>
</td>
<td>
<input id="fullName" name="webObj.fullName" maxlength="20" />
</td>
</tr>
<tr>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别:</span></td>
<td>
<select id="sex" name="webObj.sex" style="width:80px">
<option value="">请选择</option>
<option value="1">男</option>
<option value="2">女</option>
</select>
</td>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;&nbsp;&nbsp;工&nbsp;&nbsp;作&nbsp;&nbsp;电&nbsp;&nbsp;话:</span></td>
<td><input id="workPhone" name="webObj.workPhone" maxlength="20"/></td>
</tr>
<tr>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态:</span></td>
<td >
<select id="status" name="webObj.status" style="width:80px;">
<option value="<%=ConstantsDict.DATA_STATE_NORMAL%>">启用</option><!-- 描述和model的相反了 -->
<option value="<%=ConstantsDict.DATA_STATE_DELETE%>">停用</option>
</select>
</td>
<td  ><span class="fieldTitle" style="font-size: 13px;">&nbsp;&nbsp;&nbsp;E&nbsp;&nbsp;-&nbsp;&nbsp;mail&nbsp;&nbsp;&nbsp;:</span></td>
<td><input id="email" name="webObj.email" maxlength="50" /></td>
</tr>
<tr>
<td>
   <span style="color:red;font-size: 12px;">*</span>
<span class="fieldTitle" style="font-size: 13px;">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</span>
</td>
<td><input id="password" name="webObj.password" type="password" maxlength="20"/>
</td>
<td style="font-size:13px;">&nbsp;&nbsp;&nbsp;是&nbsp;&nbsp;否&nbsp;&nbsp;销&nbsp;&nbsp;售:</td>
<td>
<select id="is_sell" name="webObj.is_sell">
   <option id="id_sell" value="<%=ConstantsDict.DATA_STATE_DELETE%>">否</option>
<option id="" value="<%=ConstantsDict.DATA_STATE_NORMAL%>">是</option>
</select>
</td>
</tr>
<tr>
<td><span style="color:red;font-size: 14px;">*</span><span class="fieldTitle" style="font-size: 13px;">手&nbsp;机&nbsp;&nbsp;号&nbsp;&nbsp;码:</span></td>
<td><input id="telephone" name="webObj.telePhone" maxlength="20" /></td>
<td style="font-size:13px;">&nbsp;&nbsp;&nbsp;是&nbsp;&nbsp;&nbsp;否&nbsp;&nbsp;&nbsp;SA&nbsp;:</td>
<td>
<select id="is_sa" name="webObj.is_sa">
   <option id="is_sa"value="<%=ConstantsDict.DATA_STATE_DELETE%>">否</option>
<option id="" value="<%=ConstantsDict.DATA_STATE_NORMAL%>">是</option>
</select>
</td>
</tr>
<tr>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;企&nbsp;&nbsp;业&nbsp;名&nbsp;&nbsp;称:</span></td>
<td><input type="text" id="enterpriseName" name="webObj.enterpriseName" style="width:155px;"/></td>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;&nbsp;&nbsp;居&nbsp;&nbsp;住&nbsp;&nbsp;地&nbsp;&nbsp;址:</span></td>
<td><input id="address" name="webObj.address"/></td>
</tr>
<tr>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;个&nbsp;&nbsp;人&nbsp;图&nbsp;&nbsp;片:</span></td>
<td >
<input type="hidden" id="headImageUrl" name="webObj.headImageUrl" style="width:155px;"/>
<input class="easyui-validatebox" type="file" id="headImage" name="pic" onchange="upload('headImage')"/>
</td>
    <td rowspan="5" >
    <img id="headImageUrl_imgflag"  width="150px" height="140px" alt="LOGO">
    </td>
    <!-- 身份证图片显示 -->
<td rowspan="5">
    <img id="branchId_imgflag"  width="160px" height="140px" alt="身份证图片">
    </td>
    </tr>
    <tr height="30px">
    <td></td><td>
&nbsp;上传图片规格为:&nbsp;<span class="fieldTitle" style="color:red;font-size: 13px;">400*400</span>
</td>
</tr>
<tr>
<td><span style="color:red;font-size: 12px;">*</span>
<span class="fieldTitle" style="font-size:13px;">身&nbsp;份&nbsp;证&nbsp;号&nbsp;码:</span></td>
<td><input id="branchId" name="webObj.branchId" maxlength="20" /></td>
</tr>
<tr>
    <td><span class="fieldTitle" style="font-size:13px;">&nbsp;身&nbsp;份&nbsp;证&nbsp;照&nbsp;片:</span></td>
    <td>
<input type="hidden" id="idCardUrl" name="webObj.idCardUrl"/>
<input class="easyui-validatebox" id="branchIdImage" type="file"  name="idCardPic" onchange="upload('branchIdImage')"/>
</td>
</tr>
<tr height="40px"><td></td>
<td>
&nbsp;请上传<span class="fieldTitle" style="color:red;font-size: 13px;">清晰度高</span>身份证照片
</td><td colspan="2"></td>
</tr>
<tr>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</span></td>
<td colspan="3">
<textarea id="remark" name="webObj.remark" cols="40"   rows="4"
style="mvertical-align:top; margin-left:1px; padding-left:1px;">
</textarea>
</td>
</tr>
<tr>
<td><span class="fieldTitle" style="font-size: 13px;">&nbsp;权&nbsp;限&nbsp;&nbsp;列&nbsp;表:</span></td>
<td colspan="3">
<textarea id="roleList" name="webObj.roleList" cols="40" rows="3"
style="mvertical-align:top; margin-left:1px; padding-left:1px;" required="false" readonly="readonly">
</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-ok" onclick="add_update_functions();">保存</a>
</td>
<td colspan="2" align="center">
<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-cancel"  onclick="closeDialog('addEmployeeDlg');">取消</a>
</td>
</tr>
<tr height="20px"></tr>
</table>
</form>
</div>




----------------------------------------------------------------------------------------------

对应的上传文件JS是:

//文件上传同时把图片的url赋值给webObj.url
function upload(id){
$("#empDetailForm").attr("enctype", "multipart/form-data");
$("#empDetailForm").form("submit", {
url: 'employee!savePicUrl.action',
onSubmit:function(){
if($("#empDetailForm").form("validate"))//校验,显示上传
{
$.messager.progress({text:"上传中"});
}
return $("#empDetailForm").form("validate");
},
success:function(data){
var dataObj=eval("("+data+")");
if(id=="headImage"){
if (dataObj.imgUrl != null && dataObj.imgUrl != ""){
$("#headImageUrl_imgflag").attr("src","."+dataObj.imgUrl);
$("#headImageUrl").val(dataObj.imgUrl);

$("#headImage").val("");//清理缓存问题
$.messager.progress('close');
}
}else if(id=="branchIdImage"){
//判断是身份证图片
if (dataObj.imgUrl != null && dataObj.imgUrl != ""){
$("#branchId_imgflag").attr("src","."+dataObj.imgUrl);
$("#idCardUrl").val(dataObj.imgUrl);

$("#branchIdImage").val("");  //清空缓存
$.messager.progress('close');
}
}
}

});
}
------------------------------------------------------------------------------------------

加载中
返回顶部
顶部