上传文件的本质是浏览器读取本地文件的内容,以二进制数据方式传输到服务端,服务端新建一个文件,将获取到的数据复制到文件中

LR中上传操作可以通过web_submit_data函数实现,支持录制
要点:
web_add_header(“Content-type”,”multipart/form-data”)或者Enctype=“multipart/form-data”

一般情况需要加 web_add_header("Content-Type","multipart/form-data");

 Action()
{
web_reg_save_param("fin_msg",
"LB=",
"RB=",
"Ord=1",
"Search=Body",
LAST); web_add_header("Content-Type","multipart/form-data"); lr_start_transaction("form-data"); //上传文件---函数 web_submit_data
web_submit_data("Attachments", "Action=http://localhost:8080/pinter/file/api/upload", "Method=POST", "EncType=multipart/form-data", "TargetFrame=", "RecContentType=text/html", "Snapshot=t5.inf", "Mode=HTML", ITEMDATA, "Name=file", "Value=C:\\a.txt", "File=yes",
ENDITEM, LAST ); lr_convert_string_encoding(lr_eval_string("{fin_msg}"), LR_ENC_UTF8, LR_ENC_SYSTEM_LOCALE, "Account"); if(strcmp(lr_eval_string("{Account}"), "上传成功") == ){
lr_end_transaction("form-data", LR_PASS); }else{
lr_end_transaction("form-data", LR_FAIL); } return ;
}

运行后日志如下:

 Virtual User Script started at : -- ::
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0. for WINXP; build (Aug ::) [MsgId: MMSG-]
Run Mode: HTML [MsgId: MMSG-]
Run-Time Settings file: "C:\test_huzhenyu\Script\biao_dan_upload\\default.cfg" [MsgId: MMSG-]
Ending action vuser_init.
Running Vuser...
Starting iteration .
Starting action Action.
Action.c(): Registering web_reg_save_param was successful [MsgId: MMSG-]
Action.c(): Warning -: The header being added may cause unpredictable results when applied to all ensuing URLs. It is added anyway [MsgId: MWAR-]
Action.c(): web_add_header("Content-Type") highest severity level was "warning" [MsgId: MMSG-]
Action.c(): Notify: Transaction "form-data" started.
Action.c(): t=618ms: -byte response headers for "http://localhost:8080/pinter/file/api/upload" (RelFrameId=, Internal ID=)
Action.c(): HTTP/1.1 \r\n
Action.c(): Content-Type: text/plain;charset=UTF-\r\n
Action.c(): Content-Length: \r\n
Action.c(): Date: Sat, Mar :: GMT\r\n
Action.c(): \r\n
Action.c(): t=643ms: -byte response body for "http://localhost:8080/pinter/file/api/upload" (RelFrameId=, Internal ID=)
Action.c(): 涓婁紶鎴愬姛
Action.c(): Notify: Saving Parameter "fin_msg = 涓婁紶鎴愬姛".
Action.c(): web_submit_data("Attachments") was successful, body bytes, header bytes [MsgId: MMSG-]
Action.c(): Notify: Parameter Substitution: parameter "fin_msg" = "涓婁紶鎴愬姛"
Action.c(): Notify: Saving Parameter "Account = 上传成功\x00".
Action.c(): Notify: Parameter Substitution: parameter "Account" = "上传成功\x00"
Action.c(): Notify: Transaction "form-data" ended with "Pass" status (Duration: 0.6063 Wasted Time: 0.3921).
Ending action Action.
Ending iteration .
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

log

post接口_form表单上传的更多相关文章

  1. [转]html5表单上传控件Files API

    表单上传控件:<input type="file" />(IE9及以下不支持下面这些功能,其它浏览器最新版本均已支持.) 1.允许上传文件数量 允许选择多个文件:< ...

  2. 巨蟒python全栈开发django11:ajax&&form表单上传文件contentType

    回顾: 什么是异步? 可以开出一个线程,我发出请求,不用等待返回,可以做其他事情. 什么是同步? 同步就是,我发送出了一个请求,需要等待返回给我信息,我才可以操作其他事情. 局部刷新是什么? 通过jq ...

  3. 相册选择头像或者拍照 上传头像以NSData 图片二进制格式 表单上传

    一.点击头像图片 或者按钮 在相册选择照片返回img,网络上传头像要用data表单上传 (1)上传头像属性 // 图片二进制格式 表单上传 @property (nonatomic, strong) ...

  4. JsonResponse类的使用、form表单上传文件补充、CBV和FBV、HTML的模板语法之传值与过滤器

    昨日内容回顾 Django请求生命周期 # 1.浏览器发起请求 到达Django的socket服务端(web服务网关接口) 01 wsgiref 02 uwsgi + nginx 03 WSGI协议 ...

  5. PHP流式上传和表单上传(美图秀秀)

    最近需要开发一个头像上传的功能,找了很多都需要授权的,后来找到了美图秀秀,功能非常好用. <?php /** * Note:for octet-stream upload * 这个是流式上传PH ...

  6. Linux 基础命令-CURL 表单上传文件

    CURL -F, --form <name=content> (HTTP) This lets curl emulate a filled-in form in which a user ...

  7. 一般处理程序上传文件(html表单上传、aspx页面上传)

    html 表单上传文件        一般处理程序由于没有 apsx 页面的整个模型和控件的创建周期,而比较有效率.这里写一个用 html 表单进行文件上传的示例.        1. 表单元素选用 ...

  8. 文件的上传(表单上传和ajax文件异步上传)

    项目中用户上传总是少不了的,下面就主要的列举一下表单上传和ajax上传!注意: context.Request.Files不适合对大文件进行操作,下面列举的主要对于小文件上传的处理! 资源下载: 一. ...

  9. Android实现模拟表单上传

    很久以前,写过一篇关于下载的文章:基于HTTP协议的下载功能实现,今天对于Android上的文件上传,也简单的提两笔.在Android上,一般使用Http 模拟表单或者FTP来进行文件上传,使用FTP ...

随机推荐

  1. TCP Three-way Handshake

    TCP Connection Management Out-of-Order and Duplication(复制) Problem Old segment from previous connect ...

  2. init/loadView/viewDidLoad/initWithNibName/awakeFromNib/initWithCoder的用法

    init/loadView/viewDidLoad/viewDidUnload 这么细节的东西想来大家都不在意,平时也不会去关系,但是在面试时却常常被提到,所以了解viewController的生命周 ...

  3. java基本方法

    Java 方法 在前面几个章节中我们经常使用到 System.out.println(),那么它是什么呢? println() 是一个方法. System 是系统类. out 是标准输出对象. 这句话 ...

  4. 阿里云Docker镜像仓库(Docker Registry)

    镜像仓库申请地址: https://cr.console.aliyun.com/cn-shanghai/instances/repositories   一.创建命名空间 例如daniel-hub   ...

  5. (八)netty的SSL renegotiation攻击漏洞

    为了满足安全规范,从http改造成https(见(四)启用HTTPS),然而启用https后就可以高枕无忧了吗?绿盟告诉你:当然不,TLS Client-initiated 重协商攻击(CVE-201 ...

  6. python爬虫学习笔记(2)-----代理模式

    一.UserAgent UserAgent 中文意思是用户代理,简称UA,它是一个特殊字符串头,使得服务器能够识别用户 设置UA的两种方式: 1.heads from urllib import re ...

  7. 分布式缓存 Redis(二)

    代码实例 namespace RedisTest { class Program { static void Main(string[] args) { Student stu = RedisOper ...

  8. try catch finally 中 returne的执行顺序

    结论:1.不管有没有出现异常,finally块中代码都会执行:2.当try和catch中有return时,finally仍然会执行:3.finally是在return后面的表达式运算后执行的(此时并没 ...

  9. QEP之init()和dispatch()流程图

    抽象状态机类QFsm或QHsm有一个函数指针,用于在继承的具体状态机类中指向具体的状态函数,其有两个对外的接口函数init()和dispatch(),其工作原理是理解状态机处理事件过程的关键. 具体状 ...

  10. 03以太网帧结构(链路层 IEEE802.3)

    OSI七层模型:从底往上记(研究细致时用) 物理层:单位bit,字节byte,同轴电缆,光纤,二进制,比特流 数据链路层:帧,16进制,0-9,A-FMac地址->全网唯一性     mac地址 ...