| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 703 人关注过本帖
标题:asp 图片上传后怎么获得其路径自动填到表格中!
只看楼主 加入收藏
雨竹2009
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-10-7
收藏
 问题点数:0 回复次数:0 
asp 图片上传后怎么获得其路径自动填到表格中!
这个是一个上传asp怎么把上传好的照片显示到另一个表格中:
<%
  Response.Buffer = True
  Server.ScriptTimeOut=9999999
  On Error Resume Next
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta content="all" name="robots" />
<meta name="author" content="木目,Woodeye" />
<meta name="description" content="木目ASP文件上传工具" />
<meta name="keywords" content="木目,ASP,Upload,文件上传" />
<style type="text/css">
<!--
body,input {font-size:12px;}
-->
</style>
<title>木目ASP文件上传工具</title>
</head>
<body id="body">
<%
  ExtName = "jpg,gif,png,jpeg,tiff,bmp"    '允许扩展名
  SavePath = "img"          '保存路径
  If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/)
  CheckAndCreateFolder(SavePath)

  UpLoadAll_a = Request.TotalBytes '取得客户端全部内容
  If(UpLoadAll_a>0) Then
    Set UploadStream_c = Server.CreateObject("ADODB.Stream")
    UploadStream_c.Type = 1
    UploadStream_c.Open
    UploadStream_c.Write Request.BinaryRead(UpLoadAll_a)
    UploadStream_c.Position = 0

    FormDataAll_d = UploadStream_c.Read
    CrLf_e = chrB(13)&chrB(10)
    FormStart_f = InStrB(FormDataAll_d,CrLf_e)
    FormEnd_g = InStrB(FormStart_f+1,FormDataAll_d,CrLf_e)

    Set FormStream_h = Server.Createobject("ADODB.Stream")
    FormStream_h.Type = 1
    FormStream_h.Open
    UploadStream_c.Position = FormStart_f + 1
    UploadStream_c.CopyTo FormStream_h,FormEnd_g-FormStart_f-3
    FormStream_h.Position = 0
    FormStream_h.Type = 2
    FormStream_h.CharSet = "GB2312"
    FormStreamText_i = FormStream_h.Readtext
    FormStream_h.Close

    FileName_j = Mid(FormStreamText_i,InstrRev(FormStreamText_i,"\")+1,FormEnd_g)

    If(CheckFileExt(FileName_j,ExtName)) Then
      SaveFile = Server.MapPath(SavePath & FileName_j)

      If Err Then
        Response.Write "文件上传: <span style=""color:red;"">文件上传出错!</span> <a href=""" & Request.ServerVariables("URL") &""">重新上传文件</a><br />"
        Err.Clear
      Else
        SaveFile = CheckFileExists(SaveFile)

        k=Instrb(FormDataAll_d,CrLf_e&CrLf_e)+4
        l=Instrb(k+1,FormDataAll_d,leftB(FormDataAll_d,FormStart_f-1))-k-2
        FormStream_h.Type=1
        FormStream_h.Open
        UploadStream_c.Position=k-1
        UploadStream_c.CopyTo FormStream_h,l
        FormStream_h.SaveToFile SaveFile,2
        
        SaveFileName = Mid(SaveFile,InstrRev(SaveFile,"\")+1)
        Response.write "文件上传: <span style=""color:red;"">" & SaveFileName & " </span>文件上传成功! <a href=""" & Request.ServerVariables("URL") &""">继续上传文件</a><br />"
      End If
    Else
      Response.write "文件上传: <span style=""color:red;"">文件格式不正确!</span> <a href=""" & Request.ServerVariables("URL") &""">重新上传文件</a><br />"
    End If

  Else
%>
<script language="Javascript">
<!--
function ValidInput()
{
   
if(document.upform.upfile.value=="")
  {
    alert("请选择上传文件!")
    document.upform.upfile.focus()
    return false
  }
  return true
}
// -->
</script>
<form action='<%= Request.ServerVariables("URL") %>' method='post' name="upform" onsubmit="return ValidInput()"  enctype="multipart/form-data">
文件上传:
<input type='file' name='upfile' size="40"> <input type='submit' value="上传">
</form>
<%
  End if
  Set FormStream_h = Nothing
  UploadStream.Close
  Set UploadStream = Nothing
%>
</body>
</html>
<%
  '判断文件类型是否合格
  Function CheckFileExt(FileName,ExtName) '文件名,允许上传文件类型
    FileType = ExtName
    FileType = Split(FileType,",")
    For i = 0 To Ubound(FileType)
      If LCase(Right(FileName,3)) = LCase(FileType(i)) then
      CheckFileExt = True
      Exit Function
      Else
      CheckFileExt = False
      End if
    Next
  End Function

  '检查上传文件夹是否存在,不存在则创建文件夹
  Function CheckAndCreateFolder(FolderName)
    fldr = Server.Mappath(FolderName)
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(fldr) Then
      fso.CreateFolder(fldr)
    End If
    Set fso = Nothing
  End Function

'检查文件是否存在,重命名存在文件
Function CheckFileExists(FileName)
  Set fso=Server.CreateObject("Scripting.FileSystemObject")
  If fso.FileExists(SaveFile) Then
    i=1
    msg=True
    Do While msg
      CheckFileExists = Replace(SaveFile,Right(SaveFile,4),"_" & i & Right(SaveFile,4))
      If not fso.FileExists(CheckFileExists) Then
        msg=False
      End If
      i=i+1
    Loop
  Else
    CheckFileExists = FileName
  End If
  Set fso=Nothing
End Function
%> =======================================================================================================
下边这个是要填入的页面在照片表格中显示!
<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/config.asp"-->
<HTML>
<HEAD>
<TITLE><%=Title & " " & currentAspFileName()%></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<LINK HREF="css/css.css" REL="stylesheet" TYPE="text/css">
<SCRIPT LANGUAGE="javascript" SRC="js/js.js"></SCRIPT>
<style type="text/css">
<!--
#apDiv1 {    position:absolute;
    left:25px;
    top:96px;
    width:423px;
    height:55px;
    z-index:1;
}
-->
</style>
</HEAD>
<script type="text/javascript" src="flashfloat.js"></script>
<script type="text/javascript" src="flashobject.js"></script>

<BODY LEFTMARGIN="0" TOPMARGIN="0">
<img src="images/index.jpg" width="950" height="195">
<%
If CheckQuery(Request.QueryString("id"), "noblank") = False Then
    Call ShowInfo("参数错误!")
    Response.End()
End If

Dim sql,Rs
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select top 1 * from [teacher] where [编号] = " & Request.QueryString("id") & ""
Rs.Open sql, conn, 1, 1


If Rs.Recordcount=0 Then
    Call ShowInfo("未找到指定记录!")
    Response.End()
End If
%>
<TABLE BORDER="1" ALIGN="center" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
  <tr>
    <td width="84" nowrap>[姓名]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("姓名"))%>&nbsp;</td>
</tr>

<tr>
    <td nowrap>[性别]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("性别"))%>&nbsp;</td>
</tr>

<tr>
    <td nowrap>[年龄]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("年龄"))%>&nbsp;</td>
</tr>

<tr>
    <td nowrap>[出生年月]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("出生年月"))%>&nbsp;</td>
</tr>

<tr>
    <td height="60" nowrap>[相片]</td>
    <td width="0"></td>
    <td width="692">&nbsp;<img name="" src="upload/showimg.asp?id=<%=whatid%>" width="160" height="144" alt="照片" style="background-color: #CCCCCC"><%=htmEncodeStr(Rs("相片"))%></td>
</tr>

<tr>
    <td nowrap>[最高学历]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("最高学历"))%>&nbsp;</td>
</tr>

<tr>
    <td nowrap>[最高学历专业]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("最高学历专业"))%>&nbsp;</td>
</tr>

<tr>
    <td nowrap>[职称]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("职称"))%>&nbsp;</td>
</tr>

<tr>
    <td nowrap>[所在系]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("所在系"))%>&nbsp;</td>
</tr>
<tr>
    <td nowrap>[联系电话]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("联系电话"))%>&nbsp;</td>
</tr>
<tr>
    <td nowrap>[email]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("email"))%>&nbsp;</td>
</tr>
<tr>
    <td nowrap>[家庭住址]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("家庭住址"))%>&nbsp;</td>
</tr>
<tr>
    <td nowrap>[其他]</td>
    <td width="0"></td>
    <td width="692"><%=htmEncodeStr(Rs("其他"))%>&nbsp;</td>
</tr>
</TABLE>
<%
Rs.Close()
Set Rs = Nothing
connClose()

CheckError()
%>
</BODY>
</HTML>
======================================================================================================
演示地址:http://wangyu.web.
搜索更多相关主题的帖子: 自动 asp 路径 表格 
2009-10-07 10:20
快速回复:asp 图片上传后怎么获得其路径自动填到表格中!
数据加载中...
 
   



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

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