高分求助一个奇怪问题

sundayyoung 2007-10-15 10:54:09
我网站有一个商品信息提交的功能,现在出现这样一个有趣的问题:
当我用ie打开网页可以正常输入信息,但图片提交有问题;
当我用Mozilla firefox打开网页,图片提交没有问题,但文本框无法输入任何信息。

然而我觉得代码没有问题,是不是浏览器的什么设置有问题啊?百思不得其解,向大家求助,,,谢谢!!

图片上传代码:
<!--#include file="chk.asp"-->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="AdminStyle.css" rel="stylesheet" type="text/css">
<title>图片上传</title>
<script language="JavaScript">
var imageObject;
function ResizeImage(obj, MaxW, MaxH)
{
if (obj != null) imageObject = obj;
var state=imageObject.readyState;
var oldImage = new Image();
oldImage.src = imageObject.src;
var dW=oldImage.width; var dH=oldImage.height;
if(dW>MaxW || dH>MaxH) {
a=dW/MaxW; b=dH/MaxH;
if(b>a) a=b;
dW=dW/a; dH=dH/a;
}
if(dW > 0 && dH > 0)
imageObject.width=dW;imageObject.height=dH;
if(state!='complete' || imageObject.width>MaxW || imageObject.height>MaxH) {
setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",40);
}
}

function findItem(n, d) {
var p,x,i;
if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all)
x=d.all[n];
for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=findItem(n,d.layers[i].document);
return x;
}

</script>
<script language="javascript">
function checkImage(sId)
{
if(( document.all[sId].value.indexOf(".gif") == -1) && (document.all[sId].value.indexOf(".jpg") == -1)&& (document.all[sId].value.indexOf(".bmp") == -1) && ( document.all[sId].value.indexOf(".jpeg") == -1) && (document.all[sId].value.indexOf(".png") == -1) && (document.all[sId].value.indexOf(".swf") == -1)) {
alert("请选择gif或jpg或jpeg或png或bmp格式的文件");
event.returnValue = false;
}
else
{
esave.style.visibility="visible";
}
}
</script>
</head>

<body>

<form name="form1" method="post" action="upfile1.asp" enctype="multipart/form-data"
onsubmit="checkImage('FormName')">
<input type="hidden" name="filepath" value="../upimg/"><input type="hidden" name="action"
value="<%=request("action")%>"><input type="hidden" name="Fname"
value="<%=request("Fname")%>"><input type="hidden" name="flag"
value="<%=request("flag")%>"><table border="0" width="100%" id="table1" cellspacing="0"
cellpadding="4">
<tr>
<td>图片预览:<img name="thisImage" id="thisImage" src="../images/no_photo.gif"
onload="javascript:ResizeImage(thisImage,500,500);" width="102" height="49"></td>
</tr>
</table>
<p><input type="file" name="FormName"
onchange="javascript:findItem('thisImage').src = findItem('FormName').value;"> <input
type="submit" name="Submit" value="上传"> </p>
</form>
</body>
</html>
...全文
94 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jack_Senlan 2007-11-07
  • 打赏
  • 举报
回复
帮你顶了
lkh42002 2007-11-07
  • 打赏
  • 举报
回复
把document.all 改成document.forms["form1"]
philcc 2007-11-07
  • 打赏
  • 举报
回复
js造成的
sundayyoung 2007-11-06
  • 打赏
  • 举报
回复
请问JS怎么改啊?????谢谢大家了,帮个忙吧!!!
littlelam 2007-10-16
  • 打赏
  • 举报
回复
上面有一点写错了不是用Request.Form("action")取值
应该是用
upfile.file("action")等
upfile是上传类的上传对象

<%OPTION EXPLICIT%>
<!--#include FILE="upfile_class.asp"-->
<%
dim upfile,formPath,ServerPath,FSPath,formName,FileName,oFile,upfilecount
upfilecount=0
set upfile=new upfile_class ''建立上传对象
upfile.NoAllowExt="asp;exe;htm;html;aspx;cs;vb;js;" '设置上传类型的黑名单
upfile.GetData (10240000) '取得上传数据,限制最大上传10M
%>
<html>
<head>
<title>文件上传</title>
<style type="text/css">
<!--
.p9{ font-size: 9pt; font-family: 宋体 }
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="20" topmargin="20" class="p9">
<p class="tx1"><font color="#0000FF" size="4"><%=upfile.Version%> </font></p>
<hr size=1 noshadow width=300 align=left><%
if upfile.isErr then '如果出错
select case upfile.isErr
case 1
Response.Write "你没有上传数据呀???是不是搞错了??"
case 2
Response.Write "你上传的文件超出我们的限制,最大10M"
end select
else
%>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" class="p9" style="border-collapse: collapse">
<tr bgcolor="#CCCCCC">
<td height="25" valign='middle'> 本地文件 </td>
<td valign='middle'> 大小(字节) </td>
<td valign='middle'> 上传到 </td>
<td valign='middle'> 状态 </td>
</tr>
<%
FSPath=GetFilePath(Server.mappath("upfile.asp"),"\")'取得当前文件在服务器路径
ServerPath=GetFilePath(Request.ServerVariables("HTTP_REFERER"),"/")'取得在网站上的位置
for each formName in upfile.file '列出所有上传了的文件
set oFile=upfile.file(formname)
FileName=upfile.form(formName)'取得文本域的值
if not FileName>"" then FileName=oFile.filename'如果没有输入新的文件名,就用原来的文件名
upfile.SaveToFile formname,FSPath&FileName ''保存文件 也可以使用AutoSave来保存,参数一样,但是会自动建立新的文件名
%>
<tr>
<td height="20" valign='middle'> <%=oFile.FilePath&oFile.FileName%> </td>
<td valign='middle'> <%=oFile.filesize%> </td>
<td valign='middle'> <A HREF="<%=serverpath&FileName%>"><%=FileName%></A> </td>
<td valign='middle'> <%
if upfile.iserr then
Response.Write upfile.errmessage
else
upfilecount=upfilecount+1
Response.Write "上传成功"
end if
%> </td>
</tr><%
set oFile=nothing
next
%>
<tr>
<td colspan="3" height="25" valign='middle'> 一共上传了<%=upfileCount%>个文件</td>
</tr>
<%
end if
set upfile=nothing '删除此对象
%>
</table>
<p></p>

</p>[<a href="upfiletofile.htm">返回</a>]
<table align="center" class="p9">
<tr>
<td height="50" align="middle">版权所有 2002-2003  梁无惧 <A href="mailto:yjlrb@21cn.com">yjlrb@21cn.com</a> <br>
<a href="http://www.25cn.com">http://www.25cn.com </a>  
</td>
</tr>
</table>

</body>
</html>

<%
function GetFilePath(FullPath,str)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, str))
Else
GetFilePath = ""
End If
End function
%>
littlelam 2007-10-16
  • 打赏
  • 举报
回复
我试了没问题啊,注意有文本框的时候不能直接取得Request("action")等等的值,只能用上传类来实现,如 无惧上传类 取值用Request.Form("action")等等
如果你没用上传类的话,你的上传代码肯定是取不到action、Fname等的值的,根本就不是浏览器的问题。当enctype="multipart/form-data" 是无法正常传递的。
pzhuyy 2007-10-16
  • 打赏
  • 举报
回复
JS不一样:)
cow8063 2007-10-16
  • 打赏
  • 举报
回复
支持不同的JS,当然有这种事了,

改JS吧

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧