<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 8  文章 - 55  trackbacks - 0
    <2014年11月>
    2627282930311
    2345678
    9101112131415
    16171819202122
    23242526272829
    30123456

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    朋友的Blog

    最新評論

    閱讀排行榜

    評論排行榜

    ?
    無組件ASP文件上傳源代碼 經本人測試通過............

    無組件ASP文件上傳源代碼

    動網論壇的無組件上傳,
    以下是從動網論壇分離出來的代碼。

    如有更好用的請告訴作者
    網名:網海求生者
    QQ:54883661
    mail:wuyingke5155@163.com

    saveannounce_upload.asp 上傳頁
    ------------------------------------
    <html>
    <head>
    <style type="text/css">
    body {font-size:9pt;}
    input {font-size:9pt;}
    </style>
    <title>文件上傳</title>
    </head>
    <body>
    <form name="form" method="post" action="saveannouce_upfile.asp" enctype="multipart/form-data" >
    文件
    <input type="file" name="file1" size=10>
    <input type="submit" name="Submit" value="上傳">
    </form>
    </body>
    </html>

    ------------------------------------
    saveannouce_upfile.asp 保存文件到服務器
    ------------------------------------
    <!--#include FILE="upload.inc"-->
    <html>
    <head>
    <title>文件上傳</title>
    </head>
    <body>
    <%
    dim upload,file,formName,formPath
    set upload=new upload_5xSoft ''''建立上傳對象
    formPath=upload.form("filepath") ''''在目錄后加(/)
    if right(formPath,1)<>"/" then formPath=formPath&"/"
    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>500*1000 then ''設置上傳文件大小為500K
    response.write "<font size=2>文件大小超過了限制 500K [ <a href=# onclick=history.go(-1)>重新上傳</a> ]</font>"
    response.end
    end if
    if file.FileSize>0 then ''''如果 FileSize > 0 說明有文件數據
    file.SaveAs Server.mappath("updata\"&file.FileName) ''''保存文件
    end if
    set file=nothing
    next
    set upload=nothing
    response.write "<font size=2>文件上傳成功 [ <a href=# onclick=history.go(-1)>繼續上傳</a> ]</font>"
    %>
    </body>
    </html>

    未完接下


    接上

    ------------------------------------
    upload.inc 建立upload對象
    ------------------------------------
    <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

    dim upfile_5xSoft_Stream

    Class upload_5xSoft

    dim Form,File,Version

    Private Sub Class_Initialize
    dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
    dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
    Version=""
    if Request.TotalBytes<1 then Exit Sub
    set Form=CreateObject("Scripting.Dictionary")
    set File=CreateObject("Scripting.Dictionary")
    set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
    upfile_5xSoft_Stream.mode=3
    upfile_5xSoft_Stream.type=1
    upfile_5xSoft_Stream.open
    upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)

    vbEnter=Chr(13)&Chr(10)
    iDivLen=inString(1,vbEnter)+1
    strDiv=subString(1,iDivLen)
    iFormStart=iDivLen
    iFormEnd=inString(iformStart,strDiv)-1
    while iFormStart < iFormEnd
    iStart=inString(iFormStart,"name=""")
    iEnd=inString(iStart+6,"""")
    mFormName=subString(iStart+6,iEnd-iStart-6)
    iFileNameStart=inString(iEnd+1,"filename=""")
    if iFileNameStart>0 and iFileNameStart<iFormEnd then
    iFileNameEnd=inString(iFileNameStart+10,"""")
    mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
    iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
    iEnd=inString(iStart+4,vbEnter&strDiv)
    if iEnd>iStart then
    mFileSize=iEnd-iStart-4
    else
    mFileSize=0
    end if
    set theFile=new FileInfo
    theFile.FileName=getFileName(mFileName)
    theFile.FilePath=getFilePath(mFileName)
    theFile.FileSize=mFileSize
    theFile.FileStart=iStart+4
    theFile.FormName=FormName
    file.add mFormName,theFile
    else
    iStart=inString(iEnd+1,vbEnter&vbEnter)
    iEnd=inString(iStart+4,vbEnter&strDiv)

    if iEnd>iStart then
    mFormValue=subString(iStart+4,iEnd-iStart-4)
    else
    mFormValue=""
    end if
    form.Add mFormName,mFormValue
    end if

    iFormStart=iformEnd+iDivLen
    iFormEnd=inString(iformStart,strDiv)-1
    wend
    End Sub

    Private Function subString(theStart,theLen)
    dim i,c,stemp
    upfile_5xSoft_Stream.Position=theStart-1
    stemp=""
    for i=1 to theLen
    if upfile_5xSoft_Stream.EOS then Exit for
    c=ascB(upfile_5xSoft_Stream.Read(1))
    If c > 127 Then
    if upfile_5xSoft_Stream.EOS then Exit for
    stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
    i=i+1
    else
    stemp=stemp&Chr(c)
    End If
    Next
    subString=stemp
    End function

    Private Function inString(theStart,varStr)
    dim i,j,bt,theLen,str
    InString=0
    Str=toByte(varStr)
    theLen=LenB(Str)
    for i=theStart to upfile_5xSoft_Stream.Size-theLen
    if i>upfile_5xSoft_Stream.size then exit Function
    upfile_5xSoft_Stream.Position=i-1
    if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
    InString=i
    for j=2 to theLen
    if upfile_5xSoft_Stream.EOS then
    inString=0
    Exit for
    end if
    if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then
    InString=0
    Exit For
    end if
    next
    if InString<>0 then Exit Function
    end if
    next
    End Function

    Private Sub Class_Terminate
    form.RemoveAll
    file.RemoveAll
    set form=nothing
    set file=nothing
    upfile_5xSoft_Stream.close
    set upfile_5xSoft_Stream=nothing
    End Sub


    Private function GetFilePath(FullPath)
    If FullPath <> "" Then
    GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
    Else
    GetFilePath = ""
    End If
    End function

    Private function GetFileName(FullPath)
    If FullPath <> "" Then
    GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
    Else
    GetFileName = ""
    End If
    End function

    Private function toByte(Str)
    dim i,iCode,c,iLow,iHigh
    toByte=""
    For i=1 To Len(Str)
    c=mid(Str,i,1)
    iCode =Asc(c)
    If iCode<0 Then iCode = iCode + 65535
    If iCode>255 Then
    iLow = Left(Hex(Asc(c)),2)
    iHigh =Right(Hex(Asc(c)),2)
    toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
    Else
    toByte = toByte & chrB(AscB(c))
    End If
    Next
    End function
    End Class


    Class FileInfo
    dim FormName,FileName,FilePath,FileSize,FileStart
    Private Sub Class_Initialize
    FileName = ""
    FilePath = ""
    FileSize = 0
    FileStart= 0
    FormName = ""
    End Sub

    Public function SaveAs(FullPath)
    dim dr,ErrorChar,i
    SaveAs=1
    if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
    if FileStart=0 or right(fullpath,1)="/" then exit function
    set dr=CreateObject("Adodb.Stream")
    dr.Mode=3
    dr.Type=1
    dr.Open
    upfile_5xSoft_Stream.position=FileStart-1
    upfile_5xSoft_Stream.copyto dr,FileSize
    dr.SaveToFile FullPath,2
    dr.Close
    set dr=nothing
    SaveAs=0
    end function
    End Class
    </SCRIPT>

    完.....................
    posted on 2006-06-13 15:27 blog搬家了--[www.ialway.com/blog] 閱讀(10951) 評論(26)  編輯  收藏 所屬分類: PHP

    FeedBack:
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2006-09-20 15:11 紅紅私服發布網
    bu hao a   回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2006-10-16 09:07 乞怪豬在學習!
    好的.我自己都在用的.  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2006-10-16 09:07 乞怪豬在學習!
    這個東東是動網上的東東.  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2008-08-19 17:08 fei
    帥 上傳成功  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2008-08-27 16:06 11
    11  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2008-09-27 01:06 1123
    我的怎么不可以啊 運行后他說我Microsoft VBScript 運行時錯誤 '800a01fa'

    類沒有被定義: 'upload_5xSoft'
    那位大哥給我解決啊  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2008-10-25 23:16 機戰私服 www.jzsf800.cn
    機戰私服 www.jzsf800.cn  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2008-10-25 23:16 www.jzsf800.cn
    www.jzsf800.cn  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2008-11-20 13:26 re
    ADODB.Stream 錯誤 '800a0bbc'

    寫入文件失敗。

    /upload.inc,行 175
      回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉][未登錄] 2008-12-19 15:17 aa
    我也報錯
      回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2009-06-15 10:07 網友
    呵呵,謝謝,我的也成功了。不成功是因為要在你的目錄里面新建一個update文件夾用來保存上傳的圖片文件
      回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉][未登錄] 2009-07-29 12:26 王雷
    有這份心...
    不錯,C回去研究一下...
    這個課題我被困擾好久了...  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2009-07-31 14:35 迷蒙蒙
    成功!謝謝!
    建一個updata文件夾  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2009-08-30 14:02 訴訟
    成功上傳。謝謝!  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2009-10-07 14:02 stf
    上傳ok  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉][未登錄] 2009-11-01 10:51 小虎
    謝謝樓主哦~~
    我今天找得快崩潰了,總算找到了一個好的啦~~

    謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2009-11-02 13:51 冰城
    需要建立一個updata的文件夾,而不是update的文件夾,而且還修改文件夾的寫入屬性。
    msn:icycity@163.com  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2009-11-17 13:31 cooleaf
    我的為什么按上述設置了還是不行呢?
    1.在C:\Inetpub\wwwroot下建一目錄“updata”;
    2.在此目錄上點右鍵屬性欄里取消只讀屬性;
    3.執行文件上傳后報錯如下:
    錯誤類型:
    ADODB.Stream (0x800A0BBC)
    寫入文件失敗。
    /upload.inc, 第 175 行


    瀏覽器類型:
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; CIBA; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2010-01-11 17:26 sunqiuli
    xiexie  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2013-11-23 13:51 wuyaog
    你好,我測試后怎么老是提示:

    Microsoft VBScript 運行時錯誤 '800a01fa'
    類沒有被定義: 'upload_5xSoft'
    \saveannouce_upfile.asp, line 17

    是哪出問題了?

      回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2014-05-23 18:20 flybrid123
    太好了!!!整整一天了!!  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2014-10-26 22:46 莎莎
    sdfs  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2014-10-26 22:48 30540562
    樓主,我找這個問題很久了,一直沒解決好.
    我測試后提示:

    Microsoft VBScript 運行時錯誤 '800a01fa'
    類沒有被定義: 'upload_5xSoft'
    \saveannouce_upfile.asp, line 17

    是哪出問題了?
      回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2014-11-10 09:11 keven
    因為你upload.inc類沒有調用正確,upload.inc這個寫進去你肯定需要用<%%>將方法包含起來的  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉] 2014-11-20 19:32 
    為什么上傳不了,數據庫url還亂碼
    <!--#include file="../conn.asp" -->
    <!--#include file="seeion.asp"-->
    <!--#include file="../inc/upload.inc"--> /table>
    </body>
    </html>
    <%
    if Request.QueryString("act")="ok" then
    set rs=server.createobject("adodb.recordset")
    sql="select * from download"
    rs.open sql,conn,1,3
    title=request.form("title")
    ly=request.form("ly")
    zz=request.form("zz")
    body=request.form("body")
    url="..\upload\"&Trim(Request.Form("file1"))
    '''''
    dim upload,file,formName,formPath
    set upload=new upload_5xSoft ''''建立上傳對象
    formPath=upload.form("filepath") ''''在目錄后加(/)
    if right(formPath,1)<>"/" then formPath=formPath&"/"
    for each formName in upload.file ''''列出所有上傳了的文件
    set file=upload.file(formName) ''''生成一個文件對象


    if file.FileSize>0 then ''''如果 FileSize > 0 說明有文件數據
    file.SaveAs Server.mappath("..\upload\"&file.FileName) ''''保存文件
    end if
    set file=nothing
    next
    set upload=nothing

    ''''

    if title="" then
    response.Write("<script language=javascript>alert('下載名稱不能為空!');history.go(-1)</script>")
    response.end
    end if
    if url="" then
    response.Write("<script language=javascript>alert('下載地址不能為空!');history.go(-1)</script>")
    response.end
    end if
    if body="" then
    response.Write("<script language=javascript>alert('內容不能為空!');history.go(-1)</script>")
    response.end
    end if
    rs.addnew
    rs("title")=title
    rs("ly")=ly
    rs("zz")=zz
    rs("body")=body
    rs("url")=url
    rs.update
    rs.close
    set rs=nothing
    conn.close
    set rs=nothing
    Response.Write "<script>alert('恭喜你,下載資源增加成功,點擊繼續添加!');window.location.href='add_download.asp';</script>"
    end if
    %>  回復  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經本人測試通過............ [轉][未登錄] 2015-05-15 10:52 匿名
    An error occurred on the server when processing the URL. Please contact the system administrator.
    If you are the system administrator please click here to find out more about this error
    出現這個是什么原因?  回復  更多評論
      
    主站蜘蛛池模板: xxx毛茸茸的亚洲| 亚洲特级aaaaaa毛片| 最近中文字幕无吗免费高清 | 综合偷自拍亚洲乱中文字幕| 国产福利在线观看免费第一福利| 亚洲综合久久1区2区3区| 在线a免费观看最新网站| 亚洲成人国产精品| 日韩免费高清一级毛片| 国产精品亚洲不卡一区二区三区 | 日韩免费码中文在线观看| 国产精品V亚洲精品V日韩精品| 亚洲黄片手机免费观看| 国产A在亚洲线播放| 亚洲欧美第一成人网站7777 | 亚洲福利视频网址| 最新猫咪www免费人成| 香蕉视频亚洲一级| 亚洲人成电影在线播放| 久久久久久国产精品免费免费男同 | 日韩精品亚洲专区在线观看| 日韩在线视频播放免费视频完整版| 亚洲欧洲日本在线| 国产偷伦视频免费观看| 免费国产高清视频| 中文毛片无遮挡高清免费| 久久亚洲sm情趣捆绑调教| 无码专区永久免费AV网站| 精品亚洲av无码一区二区柚蜜| 久久精品亚洲福利| 色播精品免费小视频| 激情婷婷成人亚洲综合| 亚洲国产精品高清久久久| 91精品视频免费| 人人公开免费超级碰碰碰视频| 亚洲国产精品无码久久SM | 丰满人妻一区二区三区免费视频| 亚洲国产精品久久久久久| 日本特黄特色aa大片免费| 亚洲av永久无码精品天堂久久| 免费又黄又爽的视频|