Stimson (original work)
currently has many component-less upload classes. I took a look and found that most of them are quite complex. Some can only transmit text. The most important thing is that there are no ones with less than 10 lines of code:) I spent an entire night. I studied ADODB.Stream and used 6 lines of code to implement component-less 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:
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>