注册 登录
编程论坛 ASP技术论坛

ASP上传文件的问题!

发布于 2010-04-28 09:56, 825 次点击
请高手帮我看看这段代码,我想实现文件上传到服务器的一指定目录中,并且将表单内容送至数据库,以下代码该如何修改?请指导
QQ:66847958


<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file=data/conn.asp-->
<!--#include file=connfig.asp-->
<!--#include file=inc/yan.asp-->
<%
    set basp=Server.CreateObject("basp21")
    totby=Request.TotalBytes
    binrd=Request.BinaryRead(totby)
    fn=basp.FormFileName(binrd,"flname")
    fs=basp.FormFileSize(binrd,"flname")
    fpath=Mid(fn,InstrRev(fn,"\")+1)
    fpath=Server.Mappath("/work")&"/"&fpath
    If basp.FileCheck(fpath)>=0 and basp.Form(binrd,"direct")="cover" then
    Response.write"Server上已有同名文件,upload失败"
    else
    leng=basp.FormSaveAs(binrd,"flname",fpath)
   
    end if
    %>
<%
call case3
if request.QueryString("post")="true" then
call wri
end if
function wri
if request("title")<>"" and request("content")<>"" and (ps("gonggong")=1 or ps("chaoji")=1)then
set rs=server.CreateObject("adodb.recordset")
sql="select * from gonggong"
rs.open sql,conn,1,3
rs.AddNew
rs("title")=request("title")
rs("content")=request("content")
rs("name")=session("admin_name")
rs("time")=now()
rs("type")=request("YY")
rs("path")=request("flname")
rs.update
rs.close
response.Redirect("chenggong.htm")
else
response.Write("<script language=javascript>alert('请把信息填写完整')</script>")
end if
end function
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>发布文件</title>
<style type="text/css">
<!--
.style1 {
    font-size: 16px;
    font-weight: bold;
    color: #FFFFFF;
}
body,td,th {
    font-size: 12px;
}
body {
    background-color: #ffffff;
}
.style3 {color: #FFFFFF}
.style4 {
    font-size: 14px;
    color: #000000;
}
-->
</style>
<link href="biaodan.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style5 {color: #FF0000}
-->
</style>
</head>

<body>
<form name="form1" method="post" action="">
  <table width="626" height="300" border="0" align="center" cellspacing="1" bgcolor="#336699">
    <tr>
      <td height="46" colspan="2" background="images/tile_sub.gif"><div align="center" class="style1 style3 style4">发布文件</div></td>
    </tr>
    <tr>
      <td width="86" height="33" bgcolor="#FFFFFF"><div align="right">标题:</div></td>
      <td width="318" bgcolor="#FFFFFF"><input name="title" type="text" class="unnamed1" id="title" size="50">
      <input name="post" type="hidden" id="post" value="true"> </td>
    </tr>
    <tr>
      <td height="33" align="center" bgcolor="#FFFFFF">文档类型:</td>
      <td bgcolor="#FFFFFF"><select name="YY">
        <option value="UG模型文件">UG模型文件</option>
        <option value="PRO/E模型文件">PRO/E模型文件</option>
        <option value="ANSYS分析文件">ANSYS分析文件</option>
        <option value="AVL BOOST分析文件">AVL BOOST分析文件</option>
        <option value="MATLAB分析文件">MATLAB分析文件</option>
        <option value="ADAMS分析文件">ADAMS分析文件</option>
        <option value="FIRE分析文件">FIRE分析文件</option>
        <option value="其他类型分析文件">其他类型分析文件</option>
      </select>      </td>
    </tr>
    <tr>
      <td height="33" align="center" bgcolor="#FFFFFF">文件包:</td>
      <td bgcolor="#FFFFFF"><span class="style5">
      
        <input type="file" name="flname">
        (不要覆盖)<input type="checkbox" name="direct" value="cover" checked><p>

      选择文件入数据库</span></td>
    </tr>
    <tr>
      <td width="86" height="113" valign="top" bgcolor="#FFFFFF" ><div align="right">内容:</div></td>
      <td bgcolor="#FFFFFF"><textarea name="content" cols="76" rows="20" id="content" class="unnamed1"></textarea></td>
    </tr>
    <tr bgcolor="#F3F3F3">
      <td height="35" colspan="2"><div align="center">
        <input type="submit" name="Submit" value="提交">
         
        <input type="reset" name="Submit2" value="重填">
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
只有本站会员才能查看附件,请 登录
2 回复
#2
yms1232010-04-28 15:51
用的是上传类?
#3
2010-04-28 20:06
恩,是上传类!!代码改如何修改呢??


1