当前位置: 移动技术网 > IT编程>开发语言>Asp > 6行代码实现无组件上传(author:stimson)

6行代码实现无组件上传(author:stimson)

2017年12月12日  | 移动技术网IT编程  | 我要评论
原理代码:


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
在浏览器里面输入:

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模式不通过!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网