當前位置:編程學習大全網 - 源碼下載 - ASP上傳顯示的代碼?

ASP上傳顯示的代碼?

跨界無組件上傳類:

upload_5xsoft.inc:

& lt腳本RUNAT =服務器語言= VBSCRIPT & gt

dim Data_5xsoft

課程上傳_5xsoft

dim對象形式,對象文件,版本

公共函數形式

strForm=lcase(strForm)

如果不是objForm.exists(strForm ),則

表單= " "

其他

Form=objForm(strForm)

如果…就會結束

結束功能

公共函數文件(strFile)

strFile=lcase(strFile)

如果不是objFile.exists(strFile ),則

設置文件=新文件信息

其他

set File=objFile(strFile)

如果…就會結束

結束功能

私有子類_Initialize

dim請求數據,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,文件

dim iFileSize,sFilePath,sFileType,sFormValue,sFileName

dim iFindStart,iFindEnd

dim iFormStart,iFormEnd,sFormName

Version= "華景HTTP上傳者版本2.1 "

set objForm=Server。CreateObject("腳本。字典》)

設置objFile=Server。CreateObject("腳本。字典》)

如有要求。TotalBytes & lt1然後退出接頭

設置tStream = Server。CreateObject("adodb.stream ")

set Data_5xsoft = Server。CreateObject("adodb.stream ")

Data_5xsoft。Type = 1

Data_5xsoft。模式=3

Data_5xsoft。打開

Data_5xsoft。寫請求。BinaryRead(請求。總字節數)

Data_5xsoft。位置=0

RequestData =Data_5xsoft。閱讀

iFormStart = 1

iFormEnd = LenB(RequestData)

vbCrlf = chrB(13)chrB(10)

sStart = MidB(RequestData,1,InStrB(iFormStart,RequestData,vbCrlf)-1)

iStart = LenB (sStart)

iform start = iform start+iStart+1

while(iFormStart+10)& lt;iFormEnd

iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & ampvbCrlf)+3

tStream。Type = 1

tStream。模式=3

tStream。打開

Data_5xsoft。Position = iFormStart

Data_5xsoft。復制到tStream,iInfoEnd-iFormStart

tStream。位置= 0

tStream。類型= 2

tStream。Charset ="gb2312 "

sInfo = tStream。閱讀文本

tStream。關閉

獲取表單項目的名稱

iFormStart = InStrB(iInfoEnd,RequestData,sStart)

iFindStart = InStr(22,sInfo," name= " ",1)+6

iFindEnd = InStr(iFindStart,sInfo,"""",1)

sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))

如果是文件的話。

if InStr (45,sInfo," filename= " ",1)>那麽0

設置文件=新文件信息

獲取文件名

iFindStart = InStr(iFindEnd,sInfo," filename= " ",1)+10

iFindEnd = InStr(iFindStart,sInfo,"""",1)

sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)

文件。FileName=getFileName(sFileName)

文件。FilePath=getFilePath(sFileName)

文件。FileExt=GetFileExt(sFileName)

獲取文檔類型

iFindStart = InStr(iFindEnd,sInfo," Content-Type:",1)+14

iFindEnd = InStr(iFindStart,sInfo,vbCr)

文件。FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)

文件。FileStart =iInfoEnd

文件。FileSize = iFormStart -iInfoEnd -3

文件。FormName=sFormName

如果不是objFile。存在(sFormName)那麽

objFile.add sFormName,文件

如果…就會結束

其他

如果是表單項。

tStream。Type =1

tStream。模式=3

tStream。打開

Data_5xsoft。Position = iInfoEnd

Data_5xsoft。復制到tStream,iFormStart-iInfoEnd-3

tStream。位置= 0

tStream。類型= 2

tStream。Charset ="gb2312 "

sFormValue = tStream。閱讀文本

tStream。關閉

如果objForm。存在(sFormName)那麽

obj form(s formname)= obj form(s formname)& amp;“,”& ampsFormValue

其他

objForm。添加sFormName,sFormValue

如果…就會結束

如果…就會結束

iform start = iform start+iStart+1

RequestData= " "

設置tStream =nothing

末端接頭

私有子類_終止

如有要求。TotalBytes & gt那麽0

objForm。全部刪除

objFile。全部刪除

set objForm=nothing

set objFile=nothing

Data_5xsoft。關閉

set Data _ 5xsoft =無

如果…就會結束

末端接頭

私有函數GetFilePath(FullPath)

如果FullPath & lt& gt”“那麽

GetFilePath = left(FullPath,InStrRev(FullPath," \ "))

其他

GetFilePath = " "

如果…就會結束

結束功能

私有函數GetFileExt(完整路徑)

如果FullPath & lt& gt”“那麽

GetFileExt = mid(FullPath,InStrRev(FullPath," ")+1)

其他

GetFileExt = " "

如果…就會結束

結束功能

私有函數GetFileName(完整路徑)

如果FullPath & lt& gt”“那麽

GetFileName = mid(FullPath,InStrRev(FullPath," \")+1)

其他

GetFileName = " "

如果…就會結束

結束功能

結束類

FileInfo類

dim FormName,FileName,FilePath,FileSize,FileExt,FileType,FileStart

私有子類_Initialize

文件名= " "

文件路徑= " "

文件大小= 0

文件開始= 0

FormName = " "

文件類型= " "

FileExt = " "

末端接頭

公共函數另存為(完整路徑)

dim dr,ErrorChar,I

SaveAs=true

如果trim(fullpath)= " "或FileStart=0或FileName= " "或right(fullpath,1)="/",則退出函數

set dr=CreateObject("Adodb。流”)

博士模式=3

dr.Type=1

開放博士

Data_5xsoft.position=FileStart

Data_5xsoft.copyto災難恢復,文件大小

博士保存文件完整路徑,2

克洛斯博士

設置dr =無

SaveAs=false

結束功能

結束類

& lt/SCRIPT & gt;

upfile.asp:

& lt% OPTION EXPLICIT % & gt

& lt%服務器。script time out = 5000% & gt;

& lt!-# include FILE = " upload _ 5x soft . Inc "-& gt;

& lthtml & gt

& lthead & gt

& lttitle & gt文件上傳

& lt/head & gt;

& ltbody & gt

& ltbr & gt上傳轉換文檔!& ltHR size = 1 no shadow width = 300 align = left & gt;& ltbr & gt& ltbr & gt

& lt%

dim上傳,文件,表單名稱,表單路徑,iCount

Set upload=new upload_5xsoft ' '創建上傳對象。

response.write上傳版本& amp“& ltbr & gt& ltbr >;顯示上傳的類的版本。

Ifupload.form("文件路徑")= " "然後" ",以獲取上傳目錄。

HtmEnd "請輸入上傳到的目錄!"

設置上傳=無

響應.結束

其他

formPath=upload.form("filepath ")

在目錄後添加(/)。

if right(formPath,1)& lt;& gt"/"那麽formPath = formPath & amp"/"

如果…就會結束

iCount=0

對於上傳中的每個表單名稱。objform ' '列出所有表單數據。

response.write formName & amp" = " & ampupload.form(formName)和amp“& ltbr >;

然後

response.write " & ltbr >;

對於上傳中的每個表單名稱。objfile ' '列出所有上傳的文件。

Set file=upload.file(formName)' '生成文件對象。

如果文件。文件大小& gt0 then ' ' If filesize >;0表示有文件數據。

文件。save as server . mappath(formPath & amp;文件。文件名)''保存文件。

response.write文件文件路徑& amp文件。文件名& amp"(" & amp文件。文件大小& amp")= >& amp表單路徑和。文件。文件名& amp“成功了!& ltbr >;

iCount=iCount+1

如果…就會結束

設置文件=無

然後

Set upload=nothing ' '刪除此對象。

Htmend iCount & amp“上傳文件結束!”

sub HtmEnd(消息)

設置上傳=無

response.write " & ltbr >;& amp味精& amp“[& lt;a href = " " JavaScript:history . back();"" & gt返回

響應.結束

末端接頭

% & gt

& lt/body & gt;

& lt/html & gt;

測試文件upfile.html:

& lthtml & gt

& lthead & gt

& lttitle & gt在邊界上傳

& ltmeta http-equiv = " Content-Type " Content = " text/html;charset=gb2312 " >

& ltstyle type="text/css " >

& lt!-

td { font-size: 9pt}

a { color:# 000000;正文-裝飾:無}

a:hover { text-decoration:下劃線}

。tx { height:16px;寬度:30px邊框顏色:黑色黑色# 000000;邊框-頂部-寬度:0px邊框-右邊-寬度:0px邊框-底部-寬度:1px;邊框-左側-寬度:0px字體大小:9pt背景色:# eeeeee顏色:#0000FF}

。Bt { font-size:9pt;邊框-頂部-寬度:0px邊框-右邊-寬度:0px邊框-底部-寬度:0px邊框-左側-寬度:0px身高:16px;寬度:80px背景色:# eeeeee光標:手}

. tx 1 { height:20px;寬度:30px字體大小:9pt邊框:1px實心;邊框顏色:黑色黑色# 000000;顏色:#0000FF}

-& gt;

& lt/style & gt;

& lt/head & gt;

& ltbody bgcolor = " # FFFFFF " text = " # 000000 " & gt。

& ltform name = " form 1 " method = " post " action = " upfile . ASP " enctype = " multipart/form-data " & gt;

& lttable border = " 1 " cellspacing = " 0 " cell padding = " 0 " bordercolorlight = " # 000000 " bordercolordark = " # CCCCCC " width = " 91 " height = " 23 " & gt;

& lttr & gt

& ltTD align = " left " valign = " middle " height = " 18 " width = " 18 " >?& lt/TD & gt;

& ltTD bgcolor = " # CCCCCC " align = " left " valign = " middle " height = " 18 " width = " 67 " >文件上傳

& lt/tr & gt;

& lt/table & gt;

& ltbr & gt

& ltinput type = " hidden " name = " act " value = " upload " & gt。

& ltbr & gt

& lttable width = " 71% " border = " 1 " cellspacing = " 0 " cell padding = " 5 " align = " center " bordercolordark = " # CCCCCC " bordercolorlight = " # 000000 " & gt;

& lttr bgcolor = " # CCCCCC " & gt;

& ltTD height = " 22 " align = " left " valign = " middle " bgcolor = " # CCCCCC " & gt;?環境編程領域中的文件上傳

& lt/tr & gt;

& lttr align = " left " valign = " middle " bgcolor = " # eeeeee " & gt;

& ltTD bgcolor = " # eeeeee " height = " 92 " & gt。

& lt腳本語言= " javascript " & gt

函數集合id()

{

str = ' & lt' br & gt';

如果(!window . form 1 . up count . value)

window . form 1 . up count . value = 1;

for(I = 1;我& lt= window . form 1 . up count . value;i++)

Str+=' file'+I+':

window . upid . innerhtml = str+' & lt;' br & gt';

}

& lt/script & gt;

& lt李& gt要上傳的號碼

& ltinput type = " text " name = " up count " class = " tx " value = " 1 " >

& ltinput type = " Button " name = " Button " class = " Bt " onclick = " setid();"Value = "設置" >

& lt/李& gt

& ltbr & gt

& ltbr & gt

& lt李& gt上傳到:

& ltinput type = " text " name = " file path " class = " tx " style = " width:350 " value = " " & gt;

& lt/李& gt

& lt/TD & gt;

& lt/tr & gt;

& lttr align="center" valign="middle " >

& ltTD align = " left " id = " upid " height = " 122 " >文件1:

& ltinput type = " file " name = " file 1 " style = " width:400 " class = " tx 1 " value = " " & gt;

& lt/TD & gt;

& lt/tr & gt;

& lttr align = " center " valign = " middle " bgcolor = " # eeeeee " & gt;

& ltTD bgcolor = " # eeeeee " height = " 24 " & gt。

& lt輸入type = " submit " name = " submit " value = " submit " class = " Bt " >

& lt輸入type = " reset " name = " submit 2 " value = " re-execution " class = " Bt " >

& lt/TD & gt;

& lt/tr & gt;

& lt/table & gt;

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;

& lt腳本語言= " javascript " & gt

setid();

& lt/script & gt;

  • 上一篇:英文不好對學Java有弊端嗎?
  • 下一篇:casio5146手表GA-110RG怎麽調時間 然後調時鐘 (易懂) 和怎麽計時 調鬧鐘 等
  • copyright 2024編程學習大全網