Action()
{
int flen;
long filedes;
char filename[1024];
web_set_timeout("receive", "5000");
//设置参数的最大长度,注意该值必须大于文件的大小
web_set_max_html_param_len("20000");
//获取响应的全部内容,作为文件内容保存
web_reg_save_param("fcontent", "LB=", "RB=", "SEARCH=all", LAST);
lr_start_transaction("下载zip压缩包");
web_url("test-download.zip",
"URL=http://10.0.10.185/files/test-download.zip",
"Resource=1",
"RecContentType=application/zip",
"Referer=",
"Snapshot=t1.inf",
LAST);
lr_end_transaction("下载zip压缩包", LR_AUTO);
//获取响应中的文件长度
flen = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
strcpy(filename,"d:\\185download\\test-download");
strcat(filename,lr_eval_string("{Num}"));
strcat(filename,".zip");
if(flen > 0)
{
//以写方式打开文件
if((filedes = fopen(filename, "wb")) == NULL)
{
lr_output_message("Open File Failed!");
return -1;
}
//写入文件内容
fwrite(lr_eval_string("{fcontent}"), flen, 1, filedes);
//关闭文件
fclose(filedes);
}
return 0;
}