日期:2014-05-17  浏览次数:20560 次

html file 拒绝访问错误
今天遇到一个需求需要把基本资料和图片资料分成两个form表单分别提交,在提交基本资料表单然后再提交图片表单时报拒绝访问错误。查找原因是图片域文件上传采用了button的onclick事件让file.onclick代替默认的浏览所引起的js安全问题。采用css控制选择文件的样式透明,浮在选择照片的按钮上方就可以了。如下:
<form name="photoForm" id="photoForm" method="post" action="xxx.action" enctype="multipart/form-data" >
<input name="pbivo.pfid" type="hidden" id="person" value=""/>
            <table   border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="1">
<div  id="pImag32" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);width:93px;height:125px;"></div>
     <input name="pbivo.imagefile" id="imagefile" type="file" onchange="Preview(this);" style="position: absolute;left: 25%; filter: alpha(opacity = 0); width: 1px; CURSOR: hand;"
hidefocus require="false" dataType="Filter" 
msg="照片文件类型只能是(*.jpg,*.gif,*.jpeg)文件!"
accept="jpg,JPG,gif,GIF,JPEG,jpeg"/>
                      
                     </td>
                </tr>
<tr>
<td align="center" class="td13">
                      <input type="button" class="button_2" value="选择照片"   /><br>
  <input type="button" class="button_2" value="删除照片" name="delelePhoto1" onclick="deletePhoto();"/>
  </td>
                </tr>
</table>
</form>