Upload | No components I studied the no component upload, and made one of the simplest possible ways
----Use 9 lines of code to truly implement no component upload, how to say that spent half a day to write 9 lines of code is a bit of efficiency and results.
So I wrote this article.
Formsize=request.totalbytes ()
Formdata=request.binaryread (Formsize)
Dataheader=leftb (FORMDATA,INSTRB (FORMDATA,CHRB) &CHRB (10))
Strfiledata=midb (Formdata,lenb (Dataheader), LenB (FormData)-lenb (dataheader) *2-3)
HEADERPOS2=INSTRB (STRFILEDATA,CHRB (AscB ("-")) &chrb (AscB ("T")) &chrb (AscB ("Y")) &chrb (AscB ("P")) & C
HrB (AscB ("E"))
HEADERPOS3=INSTRB (HEADERPOS2,STRFILEDATA,CHRB (13))
DATAHEADER2=LEFTB (STRFILEDATA,HEADERPOS3+4)
Strfiledata=midb (Strfiledata,lenb (DataHeader2), LenB (Strfiledata))
Response.BinaryWrite (Strfiledata)
dataheader--file Header
strfiledata--the data after the header of the file, the final output value
Headerpos2--content-type: the location of
headerpos3--Example: Location of Content-type:image/gif
dataheader2--the entire front of the file header
Thought:
1. Remove file headers and tails first (e.g.-----------------------------7d230d1f940277)
2. Skip all previous information directly to find Content-type:image/gif
3. Extract useful information and fields
4. The data has come up and how to save it is simple. As for the FSO or ADODB.stream, it's up to you.
Problem:
One might say that a form cannot have only one file
That way, your data can't be extracted in such a simple way.
In fact, it's better if you separate them.
Here is the full example
Uup.htm
<a href= "http://www.cgfront.com" >www.cgfront.com</a>
<form name= "LoadFromFile" action= "uup.asp" method= "post" enctype= "Multipart/form-data" >
<input type= "Submit" name= "Submit" value= "OK" >
<input type= "File" Name= "LoadFromFile" style= "width:400" "value=" ">
</form>
Uup.asp
<%
Formsize=request.totalbytes ()
Formdata=request.binaryread (Formsize)
Dataheader=leftb (FORMDATA,INSTRB (FORMDATA,CHRB) &CHRB (10))
Strfiledata=midb (Formdata,lenb (Dataheader), LenB (FormData)-lenb (dataheader) *2-3)
HEADERPOS2=INSTRB (STRFILEDATA,CHRB (AscB ("-")) &chrb (AscB ("T")) &chrb (AscB ("Y")) &chrb (AscB ("P")) & C
HrB (AscB ("E"))
HEADERPOS3=INSTRB (HEADERPOS2,STRFILEDATA,CHRB (13))
DATAHEADER2=LEFTB (STRFILEDATA,HEADERPOS3+4)
Strfiledata=midb (Strfiledata,lenb (DataHeader2), LenB (Strfiledata))
Response.BinaryWrite (Strfiledata)
%>
If you press the CTRL + C +V key on your keyboard has been broken by you, it doesn't matter I also provide you with the corresponding test site
Http://www.cgfront.com/up/uup.htm
Finally, I hope we can teach you a lot.
Author: Leonard