The shortest component upload code (9 lines only)

zhaozj2021-02-16  66

I have studied no components and made a simple and feasible method.

---- The 9-line code truly realizes no components upload. How to say that I have written 9 lines of code for half a day. It is a bit efficient and fruitful.

So I wrote this article.

Formsize = Request.totalbytes ()

Formdata = Request.binaryRead (Formsize)

DataHeader = Leftb (Formdata, INSTRB (Formdata, Chrb (13) & 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 file is going to the file, the last output value

Headerpos2 - Content-Type: Location

Headerpos3 - for example: content-type: location / gif position

DataHeader2 - Whole front file header

thought:

1. Go directly to the file head and tail first (for example -------------------------- 7D230D1F940277)

2. Skip all the information directly to download Content-Type: Image / GIF

3. Extract useful information and fields

4. Data is commeminated as for how to save. As for use with FSO or AdoDb.stream, you will follow you.

problem:

Some people may tell a form that is not possible with only one file.

If your data cannot be used in this simple method, you cannot extract it normally.

In fact, you will do it separately, you can't do it.

Here is a complete example

Uup.htm

www.cgfront.com

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 the Ctrl C V key on your keyboard has been broken by you, it doesn't matter, I also give you a corresponding test location.

http://www.cgfront.com/up/uup.htm

Finally, I hope everyone will advise.

Author: Leonard

转载请注明原文地址:https://www.9cbs.com/read-21998.html

New Post(0)