post接口_form表单上传
上传文件的本质是浏览器读取本地文件的内容,以二进制数据方式传输到服务端,服务端新建一个文件,将获取到的数据复制到文件中
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表单上传的更多相关文章
- [转]html5表单上传控件Files API
表单上传控件:<input type="file" />(IE9及以下不支持下面这些功能,其它浏览器最新版本均已支持.) 1.允许上传文件数量 允许选择多个文件:< ...
- 巨蟒python全栈开发django11:ajax&&form表单上传文件contentType
回顾: 什么是异步? 可以开出一个线程,我发出请求,不用等待返回,可以做其他事情. 什么是同步? 同步就是,我发送出了一个请求,需要等待返回给我信息,我才可以操作其他事情. 局部刷新是什么? 通过jq ...
- 相册选择头像或者拍照 上传头像以NSData 图片二进制格式 表单上传
一.点击头像图片 或者按钮 在相册选择照片返回img,网络上传头像要用data表单上传 (1)上传头像属性 // 图片二进制格式 表单上传 @property (nonatomic, strong) ...
- JsonResponse类的使用、form表单上传文件补充、CBV和FBV、HTML的模板语法之传值与过滤器
昨日内容回顾 Django请求生命周期 # 1.浏览器发起请求 到达Django的socket服务端(web服务网关接口) 01 wsgiref 02 uwsgi + nginx 03 WSGI协议 ...
- PHP流式上传和表单上传(美图秀秀)
最近需要开发一个头像上传的功能,找了很多都需要授权的,后来找到了美图秀秀,功能非常好用. <?php /** * Note:for octet-stream upload * 这个是流式上传PH ...
- Linux 基础命令-CURL 表单上传文件
CURL -F, --form <name=content> (HTTP) This lets curl emulate a filled-in form in which a user ...
- 一般处理程序上传文件(html表单上传、aspx页面上传)
html 表单上传文件 一般处理程序由于没有 apsx 页面的整个模型和控件的创建周期,而比较有效率.这里写一个用 html 表单进行文件上传的示例. 1. 表单元素选用 ...
- 文件的上传(表单上传和ajax文件异步上传)
项目中用户上传总是少不了的,下面就主要的列举一下表单上传和ajax上传!注意: context.Request.Files不适合对大文件进行操作,下面列举的主要对于小文件上传的处理! 资源下载: 一. ...
- Android实现模拟表单上传
很久以前,写过一篇关于下载的文章:基于HTTP协议的下载功能实现,今天对于Android上的文件上传,也简单的提两笔.在Android上,一般使用Http 模拟表单或者FTP来进行文件上传,使用FTP ...
随机推荐
- HDU 1029 Ignatius and the Princess IV (map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1029 Ignatius and the Princess IV Time Limit: 2000/10 ...
- 产线事故:删除创建mysql索引
单表数据量:670W: 删除一个老的索引,新建一个新的索引. 事故原因: 先删除索引,应用访问量大,没有索引自然慢,数据库CPU飚到100%:新索引创建失败. 直接造成交易打烊. 日志: ------ ...
- IE下页面左偏移并页头空出一行解决方法
在其它浏览器下显示正常,包括360浏览器,在IE下,页面向左偏移,通过firebug查看,head标签为空,并且head标签里面的内容都跑到body标签内了,原因是有bom头,访问的页面或是加载,包含 ...
- lower_case_table_name
linux上是区分表名大小写的,但是可以通过 my.cnf文件中设置不区分! 1.找到my.cnf文件的所在地. find / -name my.cnf 找到这个文件的位置.我服务器上的位置是 /us ...
- 字符串和日期的相互转换,在oracle和mysql的用法
1. 字符串转日期格式 Oracle to_date(字符串 , 日期格式) 日期格式如下: D 一周中的星期几 DAY 天的名字,使用空格填充到9个字符 DD 月中的第几天 DDD 年中的第几天 D ...
- RAID磁盘阵列的原理
RAID概念 磁盘阵列(Redundant Arrays of Independent Disks,RAID),有“独立磁盘构成的具有冗余能力的阵列”之意.磁盘阵列是由很多价格较便宜的磁盘,以硬件(R ...
- layer 刷新某个页面
一:使用layer.open打开的子页面 window.parent.location.reload()//刷新父页面 var index = parent.layer.getFrameIndex(w ...
- nginx php-fpm 高并发优化
PHP-php-fpm配置优化 前言: 1.少安装PHP模块, 费内存 2.调高linux内核打开文件数量,可以使用这些命令(必须是root帐号)(我是修改/etc/rc.local,加入ulimit ...
- Product Helper
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; /// <summary> /// 产品 ...
- MapReduce之Map Join
一 介绍 之所以存在Reduce Join,是因为在map阶段不能获取所有需要的join字段,即:同一个key对应的字段可能位于不同map中.Reduce side join是非常低效的,因为shuf ...