最近經常有人問到這類問題,在此轉貼一下,內容:
1。數據庫表結構(Access):
UserID:Text(保存上傳文件的用戶ID)
FileContentType:Text(用來保存上傳文件的類型,eg:"Application/msword",主要用來使用戶能正確下載此文件)
FileContent:OLEObject(保存文件數據)
2。 HTML文件
muploadfile.htm
<Formname="upload_file"enctype="multipart/form-data"action="muploadfile.asp"method=post>
<inputtype=hiddenname="UserID"value="abc">
<inputtype=hiddenname="FileUploadStart">'這裡用來表示開始文件數據上傳
Filetosend:
<INPUTTYPE="file"name="file_up"size="30"><br>
<INPUTTYPE="file"name="file_up"size="30"><br>
<inputtype=hiddenname="FileUploadEnd">'這裡用來表示文件數據結束
<inputtype=submitvalue=Submit>
</Form></P><P>
3。 ASP文件
muploadfile.asp</P><P><%
Response.Expires=0
Functionbin2str(binstr)
Dimvarlen,clow,ccc,skipflag</P><P>skipflag=0
ccc=""
IfNotIsNull(binstr)Then
varlen=LenB(binstr)
Fori=1Tovarlen
Ifskipflag=0Then
clow=MidB(binstr,i,1)
IfAscB(clow)>127Then
ccc=ccc&Chr(AscW(MidB(binstr,i+1,1)&clow))
skipflag=1
Else
ccc=ccc&Chr(AscB(clow))
EndIf
Else
skipflag=0
EndIf