At present, there are many components of uploading classes. I probably read it. Most of them are written quite complicated. ADODB.STREAM , and used 6 lines of code to achieve a componentless upload:
upload.asp file code
<%
strfilename = request.querystring (Fn)
Set objstream = Server.createObject (Adodb.Stream)
objstream.type = 1 'addypebinary binary method
objstream.open
objstream.loadFromfile Strfilename
objstream.savetofile server.mappath (zslogo.gif), 2
%>
Use
Enter in the browser:
http: //xxx/upload.asp? Fn = c:/upload file/123.gif
Among them, XXX is your website domain name address, such as: www.jzxue.com
After executing, you will see a zslogo.gif under your directory, which is the file you just uploaded!
According to the principle of ASP no component upload, we expand the above code to the following code:
upload.asp file code
<%
Function Getfilename (byval Fn)
If Fn <> THETFILENAME = MID (Fn, Instrrev (Fn,/)+1) Else Getfilename =
Endfunction
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 code
<FORM NAME = UPFORM ACTION = UPLOAD.ASP METHOD = Post Enctype = Multipart/Form-Data>
<input type = file name = file1 style = width: 400px; value = />
<input type = submit name = submit value = upload file/>
</form>