html file 拒绝访问错误

本文介绍了一种解决多表单提交时图片文件上传遇到的JS安全问题的方法。通过使用CSS控制文件选择框的样式实现透明效果,并将其放置在选择照片按钮上方,避免了使用button的onclick事件引发的安全问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天遇到一个需求需要把基本资料和图片资料分成两个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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值