文件上传之asp代码,工作原理,以及post包数据格式
来源:互联网 发布:js 右键事件 编辑:程序博客网 时间:2024/06/05 09:10
1. asp上传文件代码
代码 来源于网络,我根据自己的需要进行了一定的修改.
1.1 asp代码调试
asp就是在调试上有点麻烦,关键是要将iis7中ASP模块里面的“将错误发送到浏览器”改成True.
这样可以再出错时,通过抓包看到出错信息是什么,从而修改asp代码.
另外,在asp里添加response.write("no hello")
response.write request.TotalBytes
response.write("\r\n")
response.end的效果等同于c里的printf.
1.2 asp上传文件代码
以下是代码,大家可以拿去用:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><body><%'On Error Resume NextResponse.Expires=0if request.TotalBytes = 0 thenresponse.write("TotalBytes = 0")response.endend ifresponse.write("no hello")response.write request.TotalBytesresponse.write("\r\n")if Request.TotalBytes > 0 thenset a=createobject("adodb.stream")a.Type=1a.Opena.write Request.BinaryRead(Request.TotalBytes)a.Position=0b=a.Readc=chrB(13)&chrB(10)d=clng(instrb(b,c))'response.write d'response.ende=instrb(d+1,b,c)set f=createobject("adodb.stream")f.type=1f.opena.Position=d+1response.write eresponse.write("\r\n")response.write dresponse.write("\r\n")'a.copyto f,e-d-3a.copyto f,-1f.Position=0f.type=2f.CharSet="GB2312"g=f.readtextf.Closeh=mid(g,instrRev(g,"\")+1,e)i=instrb(b,c&c)+4j=instrb(i+1,b,leftB(b,d-1))-i-2if j <1 thenset f =nothingset a =nothingresponse.write "未选择要上传的文件<a href='?'>重新上传</a>"response.endend iff.Type=1f.Opena.Position=i-1a.CopyTo f,jh = Mid(h, InStrRev(h, "filename=""") + 10, 5) '文件名固定为1.txt,因为这里我把长度固定了.f.SaveToFile server.mappath(h),2f.Closeset f=Nothinga.Closeset a=Nothingend ifIf Err.number<> 0 Thenresponse.Write err.numberresponse.Write err.DescriptionResponse.EndEnd If%>
1.3 工作原理
利用Stream的核心代码(各种名目的无组件代码都基本上是这样用的)接受二进制文件流filedata=Request.BinaryRead(filesize)
创建一个将数据写入 Stream 对象,dr.Write(FormData)stream
用SaveToFile保存为磁盘文件,dr.SaveToFile 文件名
很多写成了类的无组件上传,和这个略有所不同,但基本工作原理都一样.
1.4 <<ASP中实现文件上传方法的研究>>是一篇更详细的原理说明.
http://www.knowsky.com/4272.html
2. post数据格式说明
0 1
- 文件上传之asp代码,工作原理,以及post包数据格式
- POST上传文件的原理剖析以及实例验证
- ASP文件上传原理
- OkHttp 3.0之后版本GET、POST请求以及POST上传文件的示例代码
- asp上传文件代码
- asp 上传文件代码
- 框架学习之Structs2文件配置以及工作原理
- ASP.NET MVC POST 仿AJAX静态刷新表单上传文件以及传递数据
- ASP.NET 利用post方式上传文件
- nodejs-post文件上传原理详解
- nodejs-post文件上传原理详解
- nodejs-post文件上传原理详解
- ASP.NET的工作原理以及生命周期?
- ASP文件上传核心代码
- asp.net上传文件代码
- asp上传文件代码详解
- ASP.NET上传文件代码
- ASP上传图片文件代码
- 利用基于控制器的加密方案进行数据保护(一)
- 使用nginx构建rtmp服务器
- windows下c语言获取程序当前的执行目录,读文件的代码片
- 环境变量的前世今生(mysql tomcat)
- Windows下 maven3.0.4的安装步骤+maven配置本地仓库
- 文件上传之asp代码,工作原理,以及post包数据格式
- ubuntu Terminal使用小习惯
- DSP平台优化实例:如果可以尽量加上const、restrict等类型修饰词
- 关闭mysql的日志记录mysql-bin.000003
- RBAC原理
- 面向对象设计原则之开闭原则
- Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义(给脚本传递参数)
- mysql基础类的代码bug
- mysql优化