您好,登錄后才能下訂單哦!
Action()
{
intflen; //定義一個整型變量保存獲得文件的大小
longfiledes; //保存文件句柄
charfile[256]="\0"; //保存文件路徑及文件名
inttime ;
//設(shè)置頁面接收最大的字節(jié)數(shù),該設(shè)置應(yīng)大于下載文件的大小,此處為1MB
web_set_max_html_param_len("1024000");
//使用關(guān)聯(lián)函數(shù)獲取下載文件的內(nèi)容
web_reg_save_param_ex(
"ParamName=filecontent",
"LB=",
"RB=",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=http://10.255.0.145/download.php?userId={userID}&bigmd5={userID}&offset=0",
LAST);
//下載文件
lr_start_transaction("download");
web_url("download",
"URL=http://10.255.0.145/download.php?userId={userID}&bigmd5={userID}&offset=0",
Resource=1",
"RecContentType=application/octet-stream",
"Referer=",
LAST);
lr_end_transaction("download",LR_AUTO);
/*web_get_int_property返回上一個http請求的具體信息,如HTTP_INFO_DOWNLOAD_SIZE, HTTP_INFO_DOWNLOAD_TIME , HTTP_INFO_RETURN_CODE */
flen=web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("下載文件大小是:%d",flen);
time=web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
lr_output_message("下載時間是:%d",time);
//把“E:\\FSDownload\\%d.txt”這個字符串寫到file中
sprintf(file,"E:\\FSDownload\\%d.txt",rand());
lr_output_message("保存的路徑:%s",file);
if(flen> 0){
if((filedes= fopen(file,"wb")) == NULL){
lr_output_message("OpenFile Failed!", lr_eval_string("{filecontent}"));
return-1;
}
//把filecontent寫到filedes指針指向的文件中,每次寫flen,寫1次
fwrite(lr_eval_string("{filecontent}"),flen,1,filedes);
fclose(filedes );
}
return0;
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。