打印

asp上傳檔案功能(upload) 需使用組件Basp21.dll

asp上傳檔案功能(upload) 需使用組件Basp21.dll

整個被整死的asp上傳功能~機車到一個不行~
請先執行安裝RegSvr32 Basp21.dll
可將表單中的text也抓出塞進陣列,直拉response.write 變數,就可以print出來了
-------------------------------------------------------------------
<HTML>
<HEAD>
<Title>111.asp</Title>
<META http-equiv="Content-Type" content="text/html; charset=big5">
<META name="Generator" content="Asp Studio 1.0">
</HEAD>
<BODY>
<form id="form1" name="form1" method="post" action="111.asp" enctype="multipart/form-data">
<input type="text" name="text">
<input type="file" name="image">
<input type="submit" name="button1" value="SUBMIT">
</form>
<%
dim Upload,A,B,Text,Image,ImgName,ImgPath,RC
'// Upload為BASP21元件使用之變數
'// A為將取得的值擁有多少Bytes之變數
'// B為將取得的值轉為二進位碼的變數
'// Text為Form內的表單值得變數
'// Image為取得來源圖檔絕對路徑(含檔名)之變數
'// ImgName為來源圖檔檔名之變數
'// ImgPath為圖檔欲儲存的路徑及檔名之變數
'// RC為檢查檔案是否上傳之變數
set Upload = server.CreateObject("BASP21") '// 建立BASP21伺服器物件
A = request.TotalBytes '// 將取得的值得Bytes值
B = request.BinaryRead(A) '// 將取得的值轉為二進位碼
Text= Upload.Form(B,"text") '// 取得Form值並轉為二進位碼
Image = Upload.FormFileName(B,"image") '// 取得圖檔絕對路徑(含檔名)
ImgName = mid(Image,InStrRev(Image,"\")+1) '// 取得圖檔名稱(含副檔名) \
file=ImgName
response.Write ImgName'我寫
response.Write text '我寫
ImgPath = server.MapPath("upload") & "\" & ImgName '//你欲儲存檔案到哪裡的路徑及檔名
'// 檢查伺服器指定的路徑是否有相同的檔案
if Upload.FileCheck(ImgPath) >= 0 then
'set Upload = nothing '//清空物件[註:務必清空,否則秀出來的網頁會變成二進位碼。]
'response.Write("") &vbcrlf
'response.End
Response.Write "伺服器中有相同檔名 <br>"
else '// 若檔案不存在
'RC = Upload.FormSaveAs(B,"image",ImgPath) '//上傳檔案從Form的檔案表單image到伺服器的ImgPath
'// 檢查檔案上傳成功與否
Response.Write "伺服器中沒有相同檔名 <br>"
end if

RC = Upload.FormSaveAs(B,"image",ImgPath)
if RC > 0 then
Response.Write "檔案上傳成功 .<br>"
else
'set Upload = nothing '//清空物件[註:務必清空,否則秀出來的網頁會變成二進位碼。]
'response.Write("") &vbcrlf
'response.End
Response.Write "檔案上傳失敗 !<br>"
end if
%>
</BODY>
</HTML>
_________________
轉載於哇啾

TOP