strfilename = request.querystring("file1") set objstream = server.createobject("adodb.stream") objstream.type = 1 ' adtypebinary objstream.open objstream.loadfromfile strfilename objstream.savetofile server.mappath("123_onweb.gif"),2 |
使用方法:
把上面的代码写成upload.asp
在浏览器里面输入:
http://xxx/upload.asp?file1=c:上传文件123.gif
xxx为你的主机地址
执行完后你会看到你的目录下面多了一个123_onweb.gif
他就是你要文件
根据原理我们可以扩展以下代码:
upload.htm文件
<form name="form" action="upload.asp" method="post"> <input type="file" name="file1" value=""> <input type="submit" name="submit" value="ok"> </form> |
upload.asp文件
<% 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 %> |
本地调试成功,c/s模式不通过!
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!