标题:菜鸟求助! ASP+SQL上传问题.首先谢谢各位大虾
只看楼主
sundy0625
Rank: 1
来 自:湖南长沙
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-10-9
 问题点数:0 回复次数:1 
菜鸟求助! ASP+SQL上传问题.首先谢谢各位大虾
麻烦各位大虾帮忙看看下面这个代码进行图片文件上传为什么不行?
说明:环境ASP+SQL 上传完成后无任何错误提示.就是在数据库中没有文件.

<!--#include file="top.asp"--><%usertopview%>
<%if userflag23=0 then
response.redirect"ok.asp?action=flag"
end if

if request("action")="sc" then
id=request("id")
id=split(id,",")
set Fs=Server.CreateObject("Scripting.FileSystemObject")
set rs=Server.CreateObject("Adodb.Recordset")
for i=0 to ubound(id)
'=====================================
sql="select * from SMT_upfile where SMT_yp_id="&session("id")&" and SMT_sort=0 and SMT_id="& id(i)
rs.open sql,conn,1,1
do while not rs.eof
pic="../"&rs("SMT_fileadd")
If Fs.FileExists(server.mappath(pic)) Then
set Os = Fs.GetFile(server.mappath(pic))
Os.delete
end if
rs.movenext
loop
rs.close
conn.execute("delete from SMT_upfile where SMT_yp_id="&session("id")&" and SMT_sort=0 and SMT_id="& id(i)&" and SMT_yp_id="&session("id"))
'=====================================
next
set rs=nothing
set fs=nothing
response.redirect"ok.asp?url=my_picture.asp"
end if%>
<script>
function CheckAll(form)  {
  for (var i=0;i<form.elements.length;i++)    {
    var e = form.elements[i];
    if (e.name != 'chkall')       e.checked = form.chkall.checked;
   }
  }
</script>
<script language="JavaScript">
<!--
function checkdata() {
if( addform.SMT_filename.value =="") {
alert("\上传文件出错,下面是产生错误的可能原因:\n\n·请输入文件名称")
return false;
}
return true;
}
// -->
</script>

<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<tr>
<td width="160" valign=top bgcolor=#efefef>
<!--==============-->
<!--#include file="left.asp"-->
<!--==============-->
</td>
<td width="600" valign=top>
<!--==============-->
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td height=25>您现在的位置是:我的公文包 > 我的图片</td></tr>
  <tr>
    <td>
<!--####################################-->
<table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor=#6C94D1>
  <tr>
    <td height=25 bgcolor=#6C94D1>  <font color=white>上传图片</font></td>
  </tr>
  <tr>
    <td bgcolor=#ffffff height=25>
<!--======-->
<table width="80%" border="0" cellspacing="0" cellpadding="0" align=center>
<tr>
  <td height=20>
<%filesize=conn.execute("select sum(SMT_filesize) from [SMT_upfile] where [SMT_yp_id]="&session("id")&" and [SMT_sort]=0")(0)
if filesize<>"" then filesize=filesize else filesize=0
if round(filesize/1024,2)<1 and  round(filesize/1024,2)<>0 then SMT_filesize="0"&round(filesize/1024,2) else SMT_filesize=round(filesize/1024,2)%>
<table width="100%" height="0" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="addform" method="post" action="my_picture_Upload.asp" enctype="multipart/form-data">
<input name="SMT_sort" type="hidden" value="0">
<input name="yysize" type="hidden" value="<%=filesize%>">

    <tr>
      <td colspan="2" height="50"><p style="line-height:150%">可上传类型:<font color=red><%=Application("OKArpic")%></font><br>允许单个上传大小:<font color=red><%=OKsizepic/1024%> K</font><br>
文档总空间:<font color=red><%=userflag7%> K</font>  已用空间:<font color=red><%=SMT_filesize%> K</font></td>
    </tr>
    <tr>
      <td width="21%" height="25" align="center">图片名称</td>
      <td width="79%"> <input type="text" name="SMT_filename" class=input maxlength="48"></td>
    </tr>
    <tr>
      <td height="25" align="center">选择地址</td>
      <td> <input name="filedata" type="file" class="TextBoxT" id="filedata" size="30"></td>
    </tr>
    <tr align="center">
      <td colspan="2" height="25"><input type="submit" name="Submit" value="上 传" class=input1> <input type="reset" name="Submit" value="重 设" class=input1></td>
    </tr>
  </form>
</table>
  
  </td>
</tr>
</table>
<!--======-->
    </td>
  </tr>
</table>
<!--####################################-->
    </td>
  </tr>
  <tr>
    <td height=10></td>
  </tr>
  <tr>
    <td>
<!--####################################-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height=25 bgcolor=#6C94D1 style="border:1px #6c94d1 solid">  <font color=white>文件管理</font></td>
  </tr>
  <tr>
    <td bgcolor=#ffffff height=25>
<!--======-->
<table width="100%" border="0" cellspacing="1" cellpadding="5" align=center bgcolor=#6C94D1>
<form name="from1" method="post" action="my_picture.asp?action=sc">
<tr bgcolor=#efefef align=center>
  <td width="6%"><img src="../img/islx.gif" align=absmiddle alt="文件属性"></td>
  <td width=*>文件名</td>
  <td width=11%>大小(K)</td>
  <td width="25%">上传时间</td>
  <td width="6%"><img src="../img/isok.gif" align=absmiddle alt="文件是否存在"></td>
  <td width="6%"><input name="chkall" type="checkbox" id="chkall" value="select" onclick="CheckAll(this.form)" style="border:0"></td>
</tr>
<%sql="select * from SMT_upfile where SMT_yp_id="&session("id")&" and SMT_sort=0 order by SMT_id desc"
set rs=server.createobject("adodb.recordset")                     
rs.open sql,conn,1,1                     
if rs.eof and rs.bof then                     
    response.write "<tr><td height=194 colspan=6 align=center bgcolor=#ffffff>暂无内容</td></tr>"
else  
'分页的实现
listnum=10
Rs.pagesize=listnum
page=Request("page")
if (page-Rs.pagecount) > 0 then
page=Rs.pagecount
elseif page = "" or page < 1 then
page = 1
end if
Rs.absolutepage=page
'编号的实现
j=rs.recordcount
j=j-(page-1)*listnum
i=0
do while not rs.eof and i<listnum%>
<tr bgcolor=#ffffff>
<%SMT_fileadd=split(rs("SMT_fileadd"),".")%>
  <td align=center><%set fs = Server.CreateObject("Scripting.FileSystemObject")
If Fs.fileExists(server.mappath("../img/images/"&SMT_fileadd(1)&".gif")) Then
response.write "<img src=""../img/images/"&SMT_fileadd(1)&".gif"" align=absmiddle alt='"&SMT_fileadd(1)&" 文件格式'>"
else
response.write "<img src=""../img/images/x.gif"" align=absmiddle alt='"&SMT_fileadd(1)&" 文件格式'>"
end if%></td>
  <td><a href="<%="../"&rs("SMT_fileadd")%>" target=_blank><%=rs("SMT_filename")%></a></td>
<%SMT_filesize=round(rs("SMT_filesize")/1024,2)%>
  <td align=right><%if SMT_filesize<1 then response.write "0"&SMT_filesize else response.write SMT_filesize%></td>
  <td><%=rs("SMT_date")%></td>
  <td align=center><%If Fs.fileExists(server.mappath("../"&rs("SMT_fileadd"))) Then
response.write "<img src=../img/isok.gif align=absmiddle alt='此文件存在'>"
end if
set fs =nothing%></td>
  <td align=center><input type="checkbox" name="ID" value="<%=rs("SMT_id")%>" style="border:0"></td>
</tr>
<%rs.movenext
i=i+1
j=j-1
loop%>
<%filename="my_picture.asp"%>
<tr><td colspan=6 align=right bgcolor=#efefef height=20>共 <%=Rs.pagecount%> 页
      <% if page=1 then %>
      <%else%>
      <a href=<%=filename%>>|<<</a>
      <a href=<%=filename%>?page=<%=page-1%>><<</a>
      <a href=<%=filename%>?page=<%=page-1%>>[<%=page-1%>]</a>
<%end if%><% if Rs.pagecount=1 then %>
<%else%>[<%=page%>]
<%end if%>
      <% if Rs.pagecount-page <> 0 then %>
      <a href=<%=filename%>?page=<%=page+1%>>[<%=page+1%>]</a>
      <a href=<%=filename%>?page=<%=page+1%>>>></a>
      <a href=<%=filename%>?page=<%=Rs.pagecount%>>>>|</a>
      <%end if%> <input type="submit" name="Submit" value="删 除" class=input1 style="height:18"></td>
<%end if%></tr>
</form>
</table>
<!--======-->
    </td>
  </tr>
</table>
<!--####################################-->
    </td>
  </tr>
</table>
<!--####################################-->
    </td>
  </tr>
</table>
<!--==============-->
</td>
</tr>
</table>
<!--====== bottom ========-->
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor=#ffffff>
<tr><td height=2 bgcolor=#6C94D1></td></tr>
  <tr>
    <td align="center" height=80><%=citybottom%></td>
  </tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: SQL ASP 
2008-10-09 03:02
sundy0625
Rank: 1
来 自:湖南长沙
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-10-9
得分:0 
问题已经解决
千辛万苦终于解决这个问题.表单提交代码\数据连接代码都没问题.结果是数据自身出了问题!

虽然没有得到各位大虾的帮助,对于各位的关注表示感谢!

2008-10-09 15:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-237137-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.242166 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved