最近经常有人问到这类问题,在此转贴一下,内容:
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