Upload | No component file Upload article has been a lot of, so here I do not want to explain the principle of no component file upload. In the ASP, the binary file data can not be directly saved into a file, so we usually use the database to save the user uploaded files.
1. database table Structure (Access):
Userid:text (save uploaded file's user ID)
Filecontenttype:text (used to save the type of upload file, eg: "Application/msword", mainly to enable users to download the file correctly)
Filecontent:ole Object (save file data)
2. HTML file
Muploadfile.htm
<form name= "Upload_file" enctype= "Multipart/form-data" action= "muploadfile.asp" method=post>
<input type=hidden name= "UserID" value= "abc" >
<input type=hidden name= "Fileuploadstart" is used here to represent starting file data uploads
File to send: <BR>
<input type= "File" Name= "file_up" size= "><br>"
<input type= "File" Name= "file_up" size= "><br>"
<input type=hidden name= "Fileuploadend" is used here to represent the end of file data
<input Type=submit value=submit>
</Form>
3. ASP files
Muploadfile.asp
<%
Response.expires=0
Function Bin2str (BINSTR)
Dim Varlen,clow,ccc,skipflag
Skipflag=0
CCC = ""
If not IsNull (BINSTR) Then
Varlen=lenb (BINSTR)
For I=1 to Varlen
If skipflag=0 Then
Clow = MidB (binstr,i,1)
If AscB (Clow) > 127 Then
CCC =CCC & Chr (AscW (MidB (binstr,i+1,1) & Clow))
Skipflag=1
Else
CCC = CCC & Chr (AscB (Clow))
End If
Else
Skipflag=0
End If
Next
End If
BIN2STR = CCC
End Function
' When you start to judge the file data
If StrComp (strFieldName, "Fileuploadstart", 1) =0 Then
Binhttpheader=midb (BINHTTPHEADER,INSTRB (Datastart + 1, Binhttpheader, divider))
Exit Do
End If
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.