Iframe中超难问题!

lisbjing 2003-08-22 03:28:25
这是主文件:Main.asp
<TABLE border=0 cellPadding=4 cellSpacing=1 width="100%">
<FORM method="POST" Action="Save_Edit.asp?id=<%=rs("id")%>" Name="Form1">
<input type="hidden" name="id" value="<%=id%>">
<TR height="25">
<TD align="center">产品图片 </td>
<TD align="left"> 
<iframe name="ad" frameborder=0 width=100% height=30 scrolling=no src=e_upload.asp?upfile=<%=rs("picture")%>></iframe>
</TD>
</TR>
</FORM>
</TABLE>


这是主文件的保存:Save_Edit.asp 主要是upfile也就是上上传文件的文件名传不回来.
set rs=server.createobject("adodb.recordset")
sql="select * from spzs where id="& request("id")
rs.open sql,conn,1,3
if request("upfile")<>"" then
rs("picture")=request("upfile")
end if


下面是上传文件:e_upload.asp
<%@ codepage ="936" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../Style.css" rel=stylesheet type=text/css>
</head>
<body leftmargin="0" topmargin="0">
<form name="form" method="post" action="e_upfile.asp" enctype="multipart/form-data" >
<input type="hidden" name="upfile" value="<%=request("upfile")%>"> <!--Edit.asp页带过来-->
<input type="hidden" name="act" value="upload">
<input type="file" name="file1" size=45><input type="hidden" name="abc" value="abc"> <!--这个input是上传类需要,没什么作用-->
<input type="submit" name="Submit" value="上传">
</form>
</body>
</html>

下面是保存文件:e_upfile.asp
<%@ codepage ="936" %>
<!--#include FILE="../../inc/upload_5xsoft.inc"-->
<%
dim upload,filename,file,formName,formPath,iCount,fileExt
set upload=new upload_5xSoft
filename=upload.form("upfile") '取得文件名
upfile=left(Filename,instrrev(Filename,".")-1) '去掉扩展名

formPath="../../picture/"
if right(formPath,1)<>"/" then formPath=formPath&"/"

iCount=0
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<100 then
response.write "<font size=2>请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
response.end
end if
if file.filesize>100000 then '100k
response.write "<font size=2>图片大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
response.end
end if
fileExt=lcase(right(file.filename,4)) '得到文件扩展名
if fileEXT<>".gif" and fileEXT<>".jpg" then
response.write "<font size=2>文件格式不对 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
response.end
end if
FileName=formPath&upfile&fileExt '文件名不变,根据扩展名重新组合成文件路径和文件名
if file.FileSize>0 then ''说明文件有数据
file.SaveAs Server.mappath(filename) ''保存文件
'response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"
response.write "<script>parent.document.forms[0].value='"&FileName&"'</script>"
session("picture")=FileName
iCount=iCount+1
end if
set file=nothing
next
set upload=nothing
session("upface")="done"
Htmend iCount & " 张图片上传成功!"
sub HtmEnd(Msg)
set upload=nothing
response.write "<font size=2>" & msg & "</font>"
response.end
end sub
%>

</body>
</html>

主要是上面的
response.write "<script>parent.document.forms[0].value='"&FileName&"'</script>"这一句,我的意思是把这里的文件名传回上一页中供save_edit.asp页使用,为何一直取不到这个upfile变量。
上传文件没有问,就是把文件名存入数据库picture字段时取不到。

请各位帮帮忙,分不够可以另开帖。
...全文
29 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
lijingxiezhuying 2004-02-21
  • 打赏
  • 举报
回复
up
lsaturn 2004-02-06
  • 打赏
  • 举报
回复
TO:阿信:
你的那个Upload是什么来的。
人家fason改了名字了,大家都还叫他阿信啊
lisbjing 2004-02-06
  • 打赏
  • 举报
回复
up
moshco 2004-01-10
  • 打赏
  • 举报
回复
哦!兄弟,对不起,说错了!

应该是这样的,你这样不行,你的上传文件名并不在你的程序文件Main.asp的表单"Form1"里面,而是在页面程序e_upload.asp的"form"表单中!这是重点,所以你提交的表单并不会接受到文件名.
给你解决办法,你要改一下程序,应该把你的文件名保存数据库放在e_upfile.asp中处理,并且用upload("upfile")来接受文件名,"request"在这里已经被屏蔽了,然后保存到数据库就可以了!
moshco 2004-01-10
  • 打赏
  • 举报
回复
哦!说错了!应该是upload("表单名")
moshco 2004-01-10
  • 打赏
  • 举报
回复
要看稻草的帮助文件啊!
request已经被屏蔽了,要用upfile("upfile")才行!
wwwliaole 2004-01-10
  • 打赏
  • 举报
回复
应该是upfile而不是Upload
关键你传回的文件应该是文本框或者是隐藏框里。
moshco 2004-01-10
  • 打赏
  • 举报
回复
呵呵!好像是稻草的无组件上传啊!让我看看先!
lisbjing 2004-01-10
  • 打赏
  • 举报
回复
up
lisbjing 2003-08-22
  • 打赏
  • 举报
回复
TO:阿信:
你的那个Upload是什么来的。
kjeny2002 2003-08-22
  • 打赏
  • 举报
回复
楼上
fason 2003-08-22
  • 打赏
  • 举报
回复
response.write "<script>parent.document.forms[0].upload.value='"&FileName&"'</script>"

28,390

社区成员

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

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