6 lines of code implementation without component upload

zhaozj2021-02-16  58

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 'adTypeBinaryobjStream.OpenobjStream.LoadFromFile strFileNameobjStream.SaveToFile Server. "123_onweb.gif", 2

How to use: Write the above code to UPLOAD.ASP Inside the browser: http: //xxx/upload.asp? File1 = c: / upload file /123.gifxxx you will see it after your host address is executed There is a 123_onweb.gif in your directory. He is you want to file! ! ! !

According to the principles we can extend the following code: UPLOAD.ASP file <% Function getFileName (Byval strfile) if strfile <> "" "" "" "/") 1) Else getFileName = "" END IFEND FUNCTION

strFileName = Request.Form ( "file1") Set objStream = Server.CreateObject ( "ADODB.Stream") objStream.Type = 1 'adTypeBinaryobjStream.OpenobjStream.LoadFromFile strFileNameobjStream.SaveToFile Server.MapPath (GetFileName (strFileName)), 2objStream.Close %>

Upload.htm file

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

New Post(0)