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

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

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

    隨筆 - 8  文章 - 55  trackbacks - 0
    <2015年5月>
    262728293012
    3456789
    10111213141516
    17181920212223
    24252627282930
    31123456

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    朋友的Blog

    最新評論

    閱讀排行榜

    評論排行榜

    ?
    無組件ASP文件上傳源代碼 經(jīng)本人測試通過............

    無組件ASP文件上傳源代碼

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

    如有更好用的請告訴作者
    網(wǎng)名:網(wǎng)海求生者
    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 保存文件到服務(wù)器
    ------------------------------------
    <!--#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 ''設(shè)置上傳文件大小為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 說明有文件數(shù)據(jù)
    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)>繼續(xù)上傳</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文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2006-09-20 15:11 紅紅私服發(fā)布網(wǎng)
    bu hao a   回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2006-10-16 09:07 乞怪豬在學(xué)習(xí)!
    好的.我自己都在用的.  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2006-10-16 09:07 乞怪豬在學(xué)習(xí)!
    這個東東是動網(wǎng)上的東東.  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2008-08-19 17:08 fei
    帥 上傳成功  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2008-08-27 16:06 11
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2008-09-27 01:06 1123
    我的怎么不可以啊 運行后他說我Microsoft VBScript 運行時錯誤 '800a01fa'

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

    寫入文件失敗。

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

    謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝謝  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2009-11-02 13:51 冰城
    需要建立一個updata的文件夾,而不是update的文件夾,而且還修改文件夾的寫入屬性。
    msn:icycity@163.com  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2009-11-17 13:31 cooleaf
    我的為什么按上述設(shè)置了還是不行呢?
    1.在C:\Inetpub\wwwroot下建一目錄“updata”;
    2.在此目錄上點右鍵屬性欄里取消只讀屬性;
    3.執(zhí)行文件上傳后報錯如下:
    錯誤類型:
    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)  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2010-01-11 17:26 sunqiuli
    xiexie  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2013-11-23 13:51 wuyaog
    你好,我測試后怎么老是提示:

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

    是哪出問題了?

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

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

    是哪出問題了?
      回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2014-11-10 09:11 keven
    因為你upload.inc類沒有調(diào)用正確,upload.inc這個寫進(jìn)去你肯定需要用<%%>將方法包含起來的  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)] 2014-11-20 19:32 
    為什么上傳不了,數(shù)據(jù)庫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 說明有文件數(shù)據(jù)
    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('內(nèi)容不能為空!');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('恭喜你,下載資源增加成功,點擊繼續(xù)添加!');window.location.href='add_download.asp';</script>"
    end if
    %>  回復(fù)  更多評論
      
    # re: 無組件ASP文件上傳源代碼 經(jīng)本人測試通過............ [轉(zhuǎn)][未登錄] 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
    出現(xiàn)這個是什么原因?  回復(fù)  更多評論
      
    主站蜘蛛池模板: 曰批视频免费30分钟成人| 麻豆国产VA免费精品高清在线| 亚洲最大的成网4438| 永久免费毛片在线播放| 美女免费视频一区二区三区| 亚洲AV无码国产精品麻豆天美| 免费人成在线视频| aa毛片免费全部播放完整| 亚洲六月丁香六月婷婷色伊人| 免费A级毛片在线播放不收费| 久久久久免费看黄a级试看| 精品亚洲av无码一区二区柚蜜| 亚洲AV无码一区二区二三区软件| 99精品全国免费观看视频| 成人性生交大片免费看好| 亚洲精品成a人在线观看夫| 337p日本欧洲亚洲大胆裸体艺术 | 久久精品免费视频观看| 亚洲av无码有乱码在线观看| 亚洲av色影在线| 免费一级做a爰片久久毛片潮喷| 在线看片免费人成视久网| 国产亚洲精品欧洲在线观看| 久久久久久亚洲精品成人| 久久亚洲AV永久无码精品| 日韩欧美一区二区三区免费观看 | 免费乱理伦在线播放| 久热中文字幕在线精品免费| 日韩免费高清播放器| 无码一区二区三区亚洲人妻| 亚洲精品人成电影网| 亚洲精品狼友在线播放| 国产禁女女网站免费看| 美女网站免费福利视频| 精品国产免费一区二区三区香蕉| 牛牛在线精品免费视频观看| 亚洲一区二区三区高清不卡| 2022年亚洲午夜一区二区福利| 国产日韩成人亚洲丁香婷婷| 国产成人高清精品免费软件 | 免费一级做a爰片性色毛片|