图片提交按钮各浏览器不兼容问题
//----------------------------------------------javascript----------------------------
<script type="text/javascript">
function preview(fileObj) {
if (fileObj.files && fileObj.files[0]) {
var lastIndex = fileObj.files[0].name.lastIndexOf(".");
var ext = fileObj.files[0].name.substring(lastIndex);
/* var allowExt=".jpg|.jpeg"; //全部图片格式类型
if(allowExt.indexOf(ext) < 0) {
alert("上传照片格式错误!");
return;
} */
if(fileObj.files[0].size/(1024*1024) > 100) {
alert("上传附件必须小于100m!");
return;
}
document.getElementById('t1').value = fileObj.value;
/* var reader = new FileReader();
reader.onload = function(e) {
$('#previewImg').attr('src', e.target.result);
};
reader.readAsDataURL(fileObj.files[0]); */
}
}
})
</script>
//----------------------------------------------------------jsp------------------------------------
<tr style="text-align:center;">
<th class="thbg">信访原件上传:</th>
<td colspan="1" style="text-align: left; ">
<div style="height:0px; overflow:hidden; width:0;">
<input type="file" name="uploadFile" id="uploadFile" onchange="preview(this)" />
</div>
<input type="text" id="t1"/><input type="button" style="height:24px; " onclick="document.getElementById('uploadFile').click();" value="浏览"/>
</td>
</tr>