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

          常用鏈接

          留言簿(6)

          隨筆分類(lèi)

          隨筆檔案

          文章分類(lèi)

          文章檔案

          朋友的Blog

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

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

          無(wú)組件ASP文件上傳源代碼

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

          如有更好用的請(qǐng)告訴作者
          網(wǎng)名:網(wǎng)海求生者
          QQ:54883661
          mail:wuyingke5155@163.com

          saveannounce_upload.asp 上傳頁(yè)
          ------------------------------------
          <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 ''''建立上傳對(duì)象
          formPath=upload.form("filepath") ''''在目錄后加(/)
          if right(formPath,1)<>"/" then formPath=formPath&"/"
          for each formName in upload.file ''''列出所有上傳了的文件
          set file=upload.file(formName) ''''生成一個(gè)文件對(duì)象
          if file.filesize<100 then
          response.write "<font size=2>請(qǐng)先選擇你要上傳的文件 [ <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>文件大小超過(guò)了限制 500K [ <a href=# onclick=history.go(-1)>重新上傳</a> ]</font>"
          response.end
          end if
          if file.FileSize>0 then ''''如果 FileSize > 0 說(shuō)明有文件數(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對(duì)象
          ------------------------------------
          <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) 評(píng)論(26)  編輯  收藏 所屬分類(lèi): PHP

          FeedBack:
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2006-09-20 15:11 紅紅私服發(fā)布網(wǎng)
          bu hao a   回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2006-10-16 09:07 乞怪豬在學(xué)習(xí)!
          好的.我自己都在用的.  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2006-10-16 09:07 乞怪豬在學(xué)習(xí)!
          這個(gè)東東是動(dòng)網(wǎng)上的東東.  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2008-08-19 17:08 fei
          帥 上傳成功  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2008-08-27 16:06 11
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2008-09-27 01:06 1123
          我的怎么不可以啊 運(yùn)行后他說(shuō)我Microsoft VBScript 運(yùn)行時(shí)錯(cuò)誤 '800a01fa'

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

          寫(xiě)入文件失敗。

          /upload.inc,行 175
            回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)][未登錄](méi) 2008-12-19 15:17 aa
          我也報(bào)錯(cuò)
            回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2009-06-15 10:07 網(wǎng)友
          呵呵,謝謝,我的也成功了。不成功是因?yàn)橐谀愕哪夸浝锩嫘陆ㄒ粋€(gè)update文件夾用來(lái)保存上傳的圖片文件
            回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)][未登錄](méi) 2009-07-29 12:26 王雷
          有這份心...
          不錯(cuò),C回去研究一下...
          這個(gè)課題我被困擾好久了...  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2009-07-31 14:35 迷蒙蒙
          成功!謝謝!
          建一個(gè)updata文件夾  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2009-08-30 14:02 訴訟
          成功上傳。謝謝!  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2009-10-07 14:02 stf
          上傳ok  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)][未登錄](méi) 2009-11-01 10:51 小虎
          謝謝樓主哦~~
          我今天找得快崩潰了,總算找到了一個(gè)好的啦~~

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


          瀏覽器類(lèi)型:
          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ù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2010-01-11 17:26 sunqiuli
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2013-11-23 13:51 wuyaog
          你好,我測(cè)試后怎么老是提示:

          Microsoft VBScript 運(yùn)行時(shí)錯(cuò)誤 '800a01fa'
          類(lèi)沒(méi)有被定義: 'upload_5xSoft'
          \saveannouce_upfile.asp, line 17

          是哪出問(wèn)題了?

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

          Microsoft VBScript 運(yùn)行時(shí)錯(cuò)誤 '800a01fa'
          類(lèi)沒(méi)有被定義: 'upload_5xSoft'
          \saveannouce_upfile.asp, line 17

          是哪出問(wèn)題了?
            回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2014-11-10 09:11 keven
          因?yàn)槟鉼pload.inc類(lèi)沒(méi)有調(diào)用正確,upload.inc這個(gè)寫(xiě)進(jìn)去你肯定需要用<%%>將方法包含起來(lái)的  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)] 2014-11-20 19:32 
          為什么上傳不了,數(shù)據(jù)庫(kù)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 ''''建立上傳對(duì)象
          formPath=upload.form("filepath") ''''在目錄后加(/)
          if right(formPath,1)<>"/" then formPath=formPath&"/"
          for each formName in upload.file ''''列出所有上傳了的文件
          set file=upload.file(formName) ''''生成一個(gè)文件對(duì)象


          if file.FileSize>0 then ''''如果 FileSize > 0 說(shuō)明有文件數(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('下載名稱(chēng)不能為空!');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('恭喜你,下載資源增加成功,點(diǎn)擊繼續(xù)添加!');window.location.href='add_download.asp';</script>"
          end if
          %>  回復(fù)  更多評(píng)論
            
          # re: 無(wú)組件ASP文件上傳源代碼 經(jīng)本人測(cè)試通過(guò)............ [轉(zhuǎn)][未登錄](méi) 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)這個(gè)是什么原因?  回復(fù)  更多評(píng)論
            
          主站蜘蛛池模板: 金川县| 赤峰市| 东莞市| 佳木斯市| 行唐县| 迁安市| 仪征市| 汤阴县| 大方县| 和硕县| 安西县| 东乡| 永仁县| 建始县| 泊头市| 巴中市| 宿松县| 同仁县| 同心县| 梁山县| 翁牛特旗| 仪陇县| 昌平区| 东宁县| 丹巴县| 轮台县| 原平市| 宁都县| 玉树县| 大同县| 湖州市| 明水县| 茶陵县| 灌阳县| 平度市| 新蔡县| 本溪市| 广宗县| 潼关县| 梅州市| 兴和县|