ASP instance: 6 lines of code implementation without component upload

Source: Internet
Author: User
There are a lot of no component upload class, I probably looked at, most of the writing is quite complex, and some incredibly can only pass text
The key is no more than 10 lines of code below:
I spent a night researching ADODB.stream and using 6 lines of code to implement a component-free 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

How to use:

Write the above code as upload.asp
Enter in the browser:
123.gif
XXX is your host address
When you're done, you'll see a 123_onweb.gif under your catalogue.
He's the one you want the file to pull!!!!

By principle we can extend the following code:
upload.asp file
<%
Function GetFileName (ByVal strfile)
If strfile <> "" Then
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
<form name= "form" action= "upload.asp" method= "POST" >
<input type= "Submit" name= "Submit" value= "OK" >
<input type= "File" Name= "File1" style= "width:400" "value=" ">
</form>



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.