6 lines of code implementation without component upload

xiaoxiao2021-03-06  72

There are currently a lot of components, I have probably looked at it. Most of them are quite complicated. Some actually can only pass the most critical. There is no 10 line code :) I spent a night, studying ADODB .Stream, and use 6 lines of code to achieve no component upload:

Strfilename = Request.QueryString ("file1")

Set objstream = Server.createObject ("adodb.stream")

Objstream.Type = 1 'adtypebinary

Objstream.open

Objstream.LoadFromFile StrfileName

Objstream.savetofile Server. "123_onweb.gif", 2

Instructions:

Write the above code as Upload.asp

Enter in the browser:

http: //xxx/upload.asp? file1 = C: / Upload File /123.gif

XXX is your host address

You will see a 123_onweb.gif in your directory.

He is you want to pull! ! ! !

According to the principles we can extend the following code:

UPLOAD.ASP file

<%

Function getFileName (Byval strfile)

IF strfile <> "" "

GetFileName = MID (Strfile, INSTRREV (Strfile, "/") 1)

Else

GetFileName = "" "

END IF

END FUNCTION

Strfilename = Request.form ("file1")

Set objstream = Server.createObject ("adodb.stream")

Objstream.Type = 1 'adtypebinary

Objstream.open

Objstream.LoadFromFile StrfileName

Objstream.savetofile server.mappath (getFileName (StrfileName), 2

Objstream.close

%>

Upload.htm file

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


New Post(0)