欢迎光临
我们一直在努力

6行代码实现无组件上传-ASP教程,ASP应用

建站超值云服务器,限时71元/月

目前有很多无组件上传类,我大概看了一下,大多写的相当复杂,有的居然还只能传文本

最关键的是没有10行代码以下的 :)

我花了一个晚上时间研究了一下adodb.stream,并且用了6行代码实现了无组件上传:

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

使用方法:

把上面的代码写成upload.asp

在浏览器里面输入:

http://xxx/upload.asp?file1=c:\上传文件\123.gif

xxx为你的主机地址

执行完后你会看到你的目录下面多了一个123_onweb.gif

他就是你要文件拉!!!!

根据原理我们可以扩展以下代码:

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

%>

upload.htm文件

<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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 6行代码实现无组件上传-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章