當前位置:首頁 » 文件傳輸 » asp上傳
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

asp上傳

發布時間: 2022-01-21 14:17:15

『壹』 ASP網站文件上傳

index.htm index.asp default.htm default.asp 一般是這幾個

『貳』 ASP上傳代碼

Asp無組件生成縮略圖

網上有不少生成縮略圖的ASP組件。若你的虛擬空間不支持注冊新組件,可能會感覺自己的網站失色不少。心晴不才,結合網上資源寫了個無組件生成縮略圖程序,僅供參考。

還是先看看基礎部分吧。首先,我們知道在頁面中顯示圖片是如下代碼:

<img src="pic.gif" border="0" width="300" height="260">

src是圖片路徑,border控制圖片邊緣寬度,width是圖片的長度,height是圖片的高度。縮略圖的生成其實就是在原始尺寸上縮放。但一般為了盡量少失真,我們都會按比例縮放。於是,獲取圖片的長寬尺寸也就成了生成縮略圖的重點。

下面便是編寫無組件生成縮略圖的步驟:

1.無組件獲取圖片大小

以前剛學ASP不久時看到過一篇利用ASCII碼實現無組件獲取圖片尺寸的文章。後來試了試,發現在獲取jpg類圖片尺寸時總是不能正確顯示,在網上查了查,居然有不少網站轉載這個程序,但沒有一家指出此程序的缺陷,也就更談不上解決缺陷的辦法了。後來又google了一下,終於找到了一篇介紹利用ADODB.stream獲取圖片尺寸的文章,按其介紹的方法,修改裡面的代碼試了試,效果真的還不錯,現在將其拿出來與大家分享:

利用ADODB.stream獲取圖片尺寸的通用類

<%
'//////////// GPS:Get Picture Size //////////////
'//////////////利用ADODB.stream獲取圖片尺寸//////////////
'/////////Cited By Leon(心晴) 2005年8月11日//////////

Class GPS
Dim aso

Private Sub Class_Initialize
Set aso=CreateObject("Adodb.Stream")
aso.Mode=3
aso.Type=1
aso.Open
End Sub

Private Sub Class_Terminate
set aso=nothing
End Sub

Private Function Bin2Str(Bin)
Dim I, Str
For I=1 to LenB(Bin)
clow=MidB(Bin,I,1)
if AscB(clow)<128 then
Str = Str & Chr(ASCB(clow))
Else
I=I+1
if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))
end If
Next
Bin2Str = Str
End Function

Private Function Num2Str(num,base,lens)
'GPS (2005-8-11)
dim ret
ret = ""
while(num>=base)
ret = (num mod base) & ret
num = (num - num mod base)/base
wend
Num2Str = right(string(lens,"0") & num & ret,lens)
End Function

Private Function Str2Num(str,base)
'GPS (2005-8-11)
dim ret
ret = 0
for i=1 to len(str)
ret = ret *base + cint(mid(str,i,1))
next
Str2Num=ret
End Function

Private Function BinVal(bin)
'GPS (2002-8-11)
dim ret
ret = 0
for i = lenb(bin) to 1 step -1
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal=ret
End Function

Private Function BinVal2(bin)
'GPS (2002-8-11)
dim ret
ret = 0
for i = 1 to lenb(bin)
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal2=ret
End Function

'///以下是調用代碼///
Function getImageSize(filespec)
'GPS (2002-8-11)
dim ret(3)
aso.LoadFromFile(filespec)
bFlag=aso.read( 還有疑問請扣 KISS 844476679如果對我的回答滿意請採納

『叄』 asp上傳文件到伺服器的代碼怎麼寫

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標題文檔</title>
</head>
<body>
<%
'On Error Resume Next
Response.Expires=0
if Request.TotalBytes then
set a=createobject("adodb.stream")
a.Type=1
a.Open
a.write Request.BinaryRead(Request.TotalBytes)
a.Position=0
b=a.Read
c=chrB(13)&chrB(10)
d=clng(instrb(b,c))
e=instrb(d+1,b,c)
set f=createobject("adodb.stream")
f.type=1
f.open
a.Position=d+1
a.to f,e-d-3
f.Position=0
f.type=2
f.CharSet="GB2312"
g=f.readtext
f.Close
h=mid(g,instrRev(g,"\")+1,e)
i=instrb(b,c&c)+4
j=instrb(i+1,b,leftB(b,d-1))-i-2
if j <1 then
set f =nothing
set a =nothing
response.write "未選擇要上傳的文件<a href='?'>重新上傳</a>"
response.end
end if
f.Type=1
f.Open
a.Position=i-1
a.CopyTo f,j

h = Mid(h, InStrRev(h, "filename=""") + 10) '這是我幫你添加的,文件名的獲取沒有正確
f.SaveToFile server.mappath("/EXCEL/"& h),2
f.Close
set f=Nothing
a.Close
set a=Nothing
'response.write "<a href="&Server.URlEncode(h)&">"&h&"</a>"
end if
If Err.number<> 0 Then
response.Write err.number
response.Write err.Description
Response.End
End If
%>
<script language="javascript">
function checkupload() {
if (document.upload_form.fe.value == "") {
alert("未選擇要上傳的文件");
return false;
}
}
</script>
<form name="upload_form" enctype="multipart/form-data" method="post" onsubmit="return(checkupload())">
<input type="file" name="fe"/>
<input type="submit" value="上傳" name="B1"/>
</form>
</body>
</html>

『肆』 如何在asp網頁中實現上傳功能

我用的是艾恩無組件上傳,文件上傳到指定文件夾,名稱以年月日時+隨機命名,鏈接上傳到資料庫。另外也可以使用OLB上傳,就是把文件以二進制形式存入資料庫。

『伍』 asp上傳程序

這個程序是沒有任何漏洞的,要想使用得更好,在上傳時和執行文件都加上許可權那就更安全了,不明白留言給我!

本程序分三個頁面及一個文件夾(UpLoadFile),具體文件代碼如下:

文件一:上傳文件頁面

<table width="670" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#999999">
<form action="upload.asp" enctype="multipart/form-data" name="form1" method="post">
<tr bgcolor="#999999">
<td width="180"><font color="#FFFFFF">項目</font></td>
<td align="center"><font color="#FFFFFF">內容</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="180">產品名稱</td>
<td>
<input name="strName" type="text" id="strName"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="180">產品圖片</td>
<td>
<input name="strPhoto" type="file" id="strPhoto"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="180">圖片格式:gif/jpg<br>
圖片大小:150K <br>
產品介紹</td>
<td>
<input name="strRemark" cols="45" rows="6" id="strRemark"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="180"> </td>
<td>
<input type="submit" name="Submit" value="提 交">
<input type="reset" name="Submit2" value="重 置"></td>
</tr>
</form>
</table>

文件二:上傳執行數據頁面

<%
OPTION EXPLICIT
Server.ScriptTimeOut=5000
%>
<!--#include FILE="UpLoadClass.asp"-->
<%
dim request2

'建立上傳對象
set request2=New UpLoadClass

'以默認設置打開上傳對象
'建議直接修改類的63,64,65,66行為自己需要的默認設置
'類的初始默認值分別為
'p_MaxSize = 153600 單文件最大150K
'p_FileType = "jpg/gif" 允許上傳jpg/gif格式文件
'p_SavePath = "" 在當前目錄保存文件,這里是相對路徑,如:「UpLoadFile/」
'p_AutoSave = 0 自動生成無重復文件名保存目標文件
'這樣每次就不要設置同樣的參數了
request2.open()
%>
<html>
<head>
<title>快速應用——風聲無組件上傳類</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="basic.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="760" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" style="border:1px solid #999999">
<tr>
<td><blockquote>
<%
'顯示類版本
response.Write("<br>"&request2.version&"<br>")

'顯示產品名稱
response.Write("<br>產品名稱:"&request2.Form("strName"))

'顯示源文件路徑與名稱
response.Write("<br>產品圖片:"&request2.Form("strPhoto_Path")&request2.Form("strPhoto_Name"))
response.Write("=>")

'顯示目標文件路徑與名稱
response.Write(request2.SavePath&request2.Form("strPhoto"))

'顯示產品介紹
response.Write("<br>產品介紹:"&request2.Form("strRemark"))

'-------說明開始------
'可以看出上面的顯示是淋漓盡致的
'文件是否需要保存由類自動判斷,這已經符合大多數情況下的應用
'如果您需要更靈活的處理,參見[進階應用]
'-------說明結束------

response.write "<br>[<a href=""javascript:history.back();"">返回</a>]"
%>
</blockquote></td>
</tr>
</table>
</body>
</html>
<%
'釋放上傳對象
set request2=nothing
%>

文件三:上傳定義文件

<%
'----------------------------------------------------------
'***************** 風聲無組件上傳類 2.0 *****************
'作者:風聲
'網站:http://www.17560.net http://www.54nb.com
'郵件:[email protected]
'版權:版權全體,源代碼公開,各種用途均可免費使用
'**********************************************************
'----------------------------------------------------------
Class UpLoadClass

Private p_MaxSize,p_FileType,p_SavePath,p_AutoSave,p_Error
Private objForm,binForm,binItem,strDate,lngTime
Public FormItem,FileItem

Public Property Get Version
Version="Rumor UpLoadClass Version 2.0"
End Property

Public Property Get Error
Error=p_Error
End Property

Public Property Get MaxSize
MaxSize=p_MaxSize
End Property
Public Property Let MaxSize(lngSize)
if isNumeric(lngSize) then
p_MaxSize=clng(lngSize)
end if
End Property

Public Property Get FileType
FileType=p_FileType
End Property
Public Property Let FileType(strType)
p_FileType=strType
End Property

Public Property Get SavePath
SavePath=p_SavePath
End Property
Public Property Let SavePath(strPath)
p_SavePath=replace(strPath,chr(0),"")
End Property

Public Property Get AutoSave
AutoSave=p_AutoSave
End Property
Public Property Let AutoSave(byVal Flag)
select case Flag
case 0:
case 1:
case 2:
case false:Flag=2
case else:Flag=0
end select
p_AutoSave=Flag
End Property

Private Sub Class_Initialize
p_Error = -1
p_MaxSize = 1536000 '單個文件大小1.5M
p_FileType = "" '可上傳任意類型文件,jpg/gif/swf
p_SavePath = "UpLoadFile/" '保存文件路徑
p_AutoSave = 1 '用原名保存圖片,0為用時間
strDate = replace(cstr(Date()),"-","")
lngTime = clng(timer()*1000)
Set binForm = Server.CreateObject("ADODB.Stream")
Set binItem = Server.CreateObject("ADODB.Stream")
Set objForm = Server.CreateObject("Scripting.Dictionary")
objForm.CompareMode = 1
End Sub

Private Sub Class_Terminate
objForm.RemoveAll
Set objForm = nothing
Set binItem = nothing
binForm.Close()
Set binForm = nothing
End Sub

Public Sub Open()
if p_Error=-1 then
p_Error=0
else
Exit Sub
end if
Dim lngRequestSize,binRequestData,strFormItem,strFileItem
Const strSplit="'"">"
lngRequestSize=Request.TotalBytes
if lngRequestSize<1 then
p_Error=4
Exit Sub
end if
binRequestData=Request.BinaryRead(lngRequestSize)
binForm.Type = 1
binForm.Open
binForm.Write binRequestData

Dim bCrLf,strSeparator,intSeparator
bCrLf=ChrB(13)&ChrB(10)

intSeparator=InstrB(1,binRequestData,bCrLf)-1
strSeparator=LeftB(binRequestData,intSeparator)

Dim p_start,p_end,strItem,strInam,intTemp,strTemp
Dim strFtyp,strFnam,strFext,lngFsiz
p_start=intSeparator+2
Do
p_end =InStrB(p_start,binRequestData,bCrLf&bCrLf)+3
binItem.Type=1
binItem.Open
binForm.Position=p_start
binForm.CopyTo binItem,p_end-p_start
binItem.Position=0
binItem.Type=2
binItem.Charset="gb2312"
strItem=binItem.ReadText
binItem.Close()

p_start=p_end
p_end =InStrB(p_start,binRequestData,strSeparator)-1
binItem.Type=1
binItem.Open
binForm.Position=p_start
lngFsiz=p_end-p_start-2
binForm.CopyTo binItem,lngFsiz

intTemp=Instr(39,strItem,"""")
strInam=Mid(strItem,39,intTemp-39)

if Instr(intTemp,strItem,"filename=""")<>0 then
if not objForm.Exists(strInam&"_From") then
strFileItem=strFileItem&strSplit&strInam
if binItem.Size<>0 then
intTemp=intTemp+13
strFtyp=Mid(strItem,Instr(intTemp,strItem,"Content-Type: ")+14)
strTemp=Mid(strItem,intTemp,Instr(intTemp,strItem,"""")-intTemp)
intTemp=InstrRev(strTemp,"\")
strFnam=Mid(strTemp,intTemp+1)
objForm.Add strInam&"_Type",strFtyp
objForm.Add strInam&"_Name",strFnam
objForm.Add strInam&"_Path",Left(strTemp,intTemp)
objForm.Add strInam&"_Size",lngFsiz
if Instr(intTemp,strTemp,".")<>0 then
strFext=Mid(strTemp,InstrRev(strTemp,".")+1)
else
strFext=""
end if
if left(strFtyp,6)="image/" then
binItem.Position=0
binItem.Type=1
strTemp=binItem.read(10)
if strcomp(strTemp,chrb(255) & chrb(216) & chrb(255) & chrb(224) & chrb(0) & chrb(16) & chrb(74) & chrb(70) & chrb(73) & chrb(70),0)=0 then
if Lcase(strFext)<>"jpg" then strFext="jpg"
binItem.Position=3
do while not binItem.EOS
do
intTemp = ascb(binItem.Read(1))
loop while intTemp = 255 and not binItem.EOS
if intTemp < 192 or intTemp > 195 then
binItem.read(Bin2Val(binItem.Read(2))-2)
else
Exit do
end if
do
intTemp = ascb(binItem.Read(1))
loop while intTemp < 255 and not binItem.EOS
loop
binItem.Read(3)
objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2))
objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2))
elseif strcomp(leftB(strTemp,8),chrb(137) & chrb(80) & chrb(78) & chrb(71) & chrb(13) & chrb(10) & chrb(26) & chrb(10),0)=0 then
if Lcase(strFext)<>"png" then strFext="png"
binItem.Position=18
objForm.Add strInam&"_Width",Bin2Val(binItem.Read(2))
binItem.Read(2)
objForm.Add strInam&"_Height",Bin2Val(binItem.Read(2))
elseif strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(57) & chrb(97),0)=0 or strcomp(leftB(strTemp,6),chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(55) & chrb(97),0)=0 then
if Lcase(strFext)<>"gif" then strFext="gif"
binItem.Position=6
objForm.Add strInam&"_Width",BinVal2(binItem.Read(2))
objForm.Add strInam&"_Height",BinVal2(binItem.Read(2))
elseif strcomp(leftB(strTemp,2),chrb(66) & chrb(77),0)=0 then
if Lcase(strFext)<>"bmp" then strFext="bmp"
binItem.Position=18
objForm.Add strInam&"_Width",BinVal2(binItem.Read(4))
objForm.Add strInam&"_Height",BinVal2(binItem.Read(4))
end if
end if
objForm.Add strInam&"_Ext",strFext
objForm.Add strInam&"_From",p_start
intTemp=GetFerr(lngFsiz,strFext)
if p_AutoSave<>2 then
objForm.Add strInam&"_Err",intTemp
if intTemp=0 then
if p_AutoSave=0 then
strFnam=GetTimeStr()
if strFext<>"" then strFnam=strFnam&"."&strFext
end if
binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2
objForm.Add strInam,strFnam
end if
end if
else
objForm.Add strInam&"_Err",-1
end if
end if
else
binItem.Position=0
binItem.Type=2
binItem.Charset="gb2312"
strTemp=binItem.ReadText
if objForm.Exists(strInam) then
objForm(strInam) = objForm(strInam)&","&strTemp
else
strFormItem=strFormItem&strSplit&strInam
objForm.Add strInam,strTemp
end if
end if

binItem.Close()
p_start = p_end+intSeparator+2
loop Until p_start+3>lngRequestSize
FormItem=split(strFormItem,strSplit)
FileItem=split(strFileItem,strSplit)
End Sub

Private Function GetTimeStr()
lngTime=lngTime+1
GetTimeStr=strDate&lngTime
End Function

Private Function GetFerr(lngFsiz,strFext)
dim intFerr
intFerr=0
if lngFsiz>p_MaxSize and p_MaxSize>0 then
if p_Error=0 or p_Error=2 then p_Error=p_Error+1
intFerr=intFerr+1
end if
if Instr(1,LCase("/"&p_FileType&"/"),LCase("/"&strFext&"/"))=0 and p_FileType<>"" then
if p_Error<2 then p_Error=p_Error+2
intFerr=intFerr+2
end if
GetFerr=intFerr
End Function

Public Function Save(Item,strFnam)
Save=false
if objForm.Exists(Item&"_From") then
dim intFerr,strFext
strFext=objForm(Item&"_Ext")
intFerr=GetFerr(objForm(Item&"_Size"),strFext)
if objForm.Exists(Item&"_Err") then
if intFerr=0 then
objForm(Item&"_Err")=0
end if
else
objForm.Add Item&"_Err",intFerr
end if
if intFerr<>0 then Exit Function
if VarType(strFnam)=2 then
select case strFnam
case 0:strFnam=GetTimeStr()
if strFext<>"" then strFnam=strFnam&"."&strFext
case 1:strFnam=objForm(Item&"_Name")
end select
end if
binItem.Type = 1
binItem.Open
binForm.Position = objForm(Item&"_From")
binForm.CopyTo binItem,objForm(Item&"_Size")
binItem.SaveToFile Server.MapPath(p_SavePath&strFnam),2
binItem.Close()
if objForm.Exists(Item) then
objForm(Item)=strFnam
else
objForm.Add Item,strFnam
end if
Save=true
end if
End Function

Public Function GetData(Item)
GetData=""
if objForm.Exists(Item&"_From") then
if GetFerr(objForm(Item&"_Size"),objForm(Item&"_Ext"))<>0 then Exit Function
binForm.Position = objForm(Item&"_From")
GetData=binFormStream.Read(objForm(Item&"_Size"))
end if
End Function

Public Function Form(Item)
if objForm.Exists(Item) then
Form=objForm(Item)
else
Form=""
end if
End Function

Private Function BinVal2(bin)
dim lngValue,i
lngValue = 0
for i = lenb(bin) to 1 step -1
lngValue = lngValue *256 + ascb(midb(bin,i,1))
next
BinVal2=lngValue
End Function

Private Function Bin2Val(bin)
dim lngValue,i
lngValue = 0
for i = 1 to lenb(bin)
lngValue = lngValue *256 + ascb(midb(bin,i,1))
next
Bin2Val=lngValue
End Function

End Class
%>

『陸』 【ASP上傳程序】

依我說 還是用別人做好的類就行了 沒必要搞的那麼明白 你只要會用遙控器就可以了 不需要知道電視的構造 風聲無組件上傳類 還不錯
如果你確定想知道電視是怎麼造的 那就把文件發到我郵箱里吧 當然 我也只是幫你參考參考 不一定能解決你的問題 還望諒解 郵箱 [email protected]

『柒』 asp如何遠程上傳文件

示例如下

<%
function saveimg(url)
dim temp,ranNum,filename,xmlhttp,imgcon,objAdostream,savepath,rdate,rfolder
savepath=server.mappath("/pic")
'response.write server.mappath("/pic")
'savepath=replace(savepath,"\","/")
'savepath=savepath&"/"
'savepath=replace(savepath,"//","/")

temp=split(url,".")
'以下是用時間與隨機數重命名文件名
rdate=now
randomize
ranNum=int(90000*rnd)+10000
filename=year(rdate)&month(rdate)&day(rdate)&hour(rdate)&minute(rdate)&second(rdate)&ranNum&"."&temp(ubound(temp))
'文件名重命名結束

'rfolder=year(rdate)&"_"&month(rdate)
'if len(month(now))<2 then
'rfolder=year(now)&"0"&month(now)
'else
'rfolder=year(now)&month(now)
'end if
'savepath=savepath&rfolder
'call FSOfolder(Server.MapPath(savepath))

set xmlhttp=server.createobject("Mi"&"cros"&"oft.XM"&"LHTTP")
xmlhttp.open "get",url,false
xmlhttp.send
imgcon=xmlhttp.ResponseBody
set xmlhttp=nothing
set objAdostream=server.createobject("AD"&"ODB"&".Str"&"eam")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(imgcon)
'response.write savepath
objAdostream.SaveToFile(savepath&"/"&filename)
objAdostream.SetEOS
set objAdostream=nothing
saveimg=savepath&"/"&filename
response.write saveimg
end function
call saveimg("http://www.sinaimg.cn/home/07index/sinahome_ws_009.gif")
%>

『捌』 ASP網頁上傳

比如你的資料庫mydata.mdb放在data文件夾裡面,conn文件路徑可以這么寫:
Const SiteDb = "/Data/mydata.mdb"

發個完整的給你參考下:
<%

function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32), "")
fString = Replace(fString, CHR(9), "")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), " ")
fString = Replace(fString, CHR(10), " ")
fString=ChkBadWords(fString)
HTMLEncode = fString
end if
end function

function checkStr(str)
if isnull(str) then
checkStr = ""
exit function
end if
checkStr=replace(str,"'","''")
end function
Const SiteDb = "/Data/mydata.mdb"

dim sessionvar
Dim ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & SiteDb)
on error resume next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "資料庫連接出錯,請檢查連接字串。"
Response.End
End If
sessionvar="admin&^jffsddasf"
%>

『玖』 asp 上傳

我們用來獲取上一個頁面傳遞過來的數據一般是使用Request對象。同樣的,我們也可以使用Request對象來獲取上傳上來的文件數據,使用的方法是Request.BinaryRead()。而我們要從資料庫中讀出來圖片的數據顯示到網頁上面要用到的方法是:

Request.BinaryWrite()。在我們得到了圖片的數據,要保存到資料庫中的時候,不可以直接使用Insert語句對資料庫進行操作,而是要使用ADO的AppendChunk方法,同樣的,讀出資料庫中的圖片數據,要使用GetChunk方法。各個方法的具體語法如下:

* Request.BinaryRead語法:

variant = Request.BinaryRead(count)
參數

variant

返回值保存著從客戶端讀取到數據。

count

指明要從客戶端讀取的數據量大小,這個值小於或者等於使用方法

Request.TotalBytes得到的數據量。

* Request.BinaryWrite語法:

Request.BinaryWrite data

參數

data

要寫入到客戶端瀏覽器中的數據包。

* Request.TotalBytes語法:

variant = Request.TotalBytes

參數

variant

返回從客戶端讀取到數據量的位元組數。

* AppendChunk語法

將數據追加到大型文本、二進制數據 Field 或 Parameter 對象。

object.AppendChunk Data

參數

object Field 或 Parameter 對象

Data 變體型,包含追加到對象中的數據。

說明

使用 Field 或 Parameter 對象的 AppendChunk 方法可將長二進制或字元數據填寫到對象中。在系統內存有限的情況下,可以使用 AppendChunk 方法對長整型值進行部分而非全部的操作。

* GetChunk語法

返回大型文本或二進制數據 Field 對象的全部或部分內容 。

variable = field.GetChunk( Size )

返回值

返回變體型。

參數

Size 長整型表達式,等於所要檢索的位元組或字元數。

說明

使用 Field 對象的 GetChunk 方法檢索其部分或全部長二進制或字元數據。在系統內存有限的情況下,可使用 GetChunk 方法處理部分而非全部的長整型值。

GetChunk 調用返回的數據將賦給「變數」。如果 Size 大於剩餘的數據,則

GetChunk 僅返回剩餘的數據而無需用空白填充「變數」。如果欄位為空,則

GetChunk 方法返回 Null。

每個後續的 GetChunk 調用將檢索從前一次 GetChunk 調用停止處開始的數據。但是,如果從一個欄位檢索數據然後在當前記錄中設置或讀取另一個欄位的值,ADO 將認為已從第一個欄位中檢索出數據。如果在第一個欄位上再次調用 GetChunk 方法,ADO 將把調用解釋為新的 GetChunk 操作並從記錄的起始處開始讀取。如果其他 Recordset 對象不是首個 Recordset 對象的副本,則訪問其中的欄位不會破壞 GetChunk 操作。如果 Field 對象的 Attributes 屬性中的 adFldLong 位設置為 True,則可以對該欄位使用 GetChunk 方法。如果在 Field 對象上使用 Getchunk 方法時沒有當前記錄,將產生錯誤 3021(無當前記錄)。