LR File Download script (file parameterized rename)

Source: Internet
Author: User
Tags save file

Http://wenku.baidu.com/link?url= 6oiiadyf9efs4vshkbfjdnxrbh2ix919ndi0jo8yoqtrnrnipavfrzj9lpvb-fbsfbryinujpuy7q2up_we559qv7ri7wqm1r7exhigbl3a The same file name will be overwritten when the file is downloaded: The following are two ways to rename the file, the Mother egg function is wrong, let me complete the morning: the first use of the strcpy function, the random number of parameterized file name will be generated each time the filename is randomly with a different number strcpy (filepath,lr_ Eval_string ("d://data export {Num}.doc")); the second is a bit more complicated. Char filename1[50];
Char filename[50];
Char filepath[50];
Generates a random number that is not duplicated,
int I=rand ()%10;
Srand (Time (NULL));
Generate a random number between 1-10, this piece of note () cannot be omitted
Lr_save_datetime ("%y%m%d%h%m%s", Date_now, "now");
This block notes the time format and whether double quotation marks are added
sprintf (filename, "%s%d.csv",
Lr_eval_string ("{now}"), i);
lr_save_string (filename, "filename1");
strcpy (filepath, "d:\\users\\wufangfang\\desktop\\app\\");
strcat (Filepath,lr_eval_string ("{filename1}"));
Lr_message ("%s", filepath ============================== Golden Split line ===============================
Define an integer variable save the size of the obtained file
int Flen;
Save File handle
Long filedes;/*
Char filename1[50];

Char filename[50];

Char filepath[50];
Generates a random number that is not duplicated,
int I=rand ()%10;
Srand (Time (NULL));
Generate a random number between 1-10, this piece of note () cannot be omitted
Lr_save_datetime ("%y%m%d%h%m%s", Date_now, "now");

This block notes the time format and whether double quotation marks are added
sprintf (filename, "%s%d.csv",
Lr_eval_string ("{now}"), i);

lr_save_string (filename, "filename1");

strcpy (filepath, "d:\\users\\wufangfang\\desktop\\app\\");
strcat (Filepath,lr_eval_string ("{filename1}"));
Lr_message ("%s", filepath); */
To set the maximum length of a parameter, note that the value must be greater than the size of the file

Web_set_max_html_param_len ("20000");


Use the correlation function to get the contents of the downloaded file, where the left and right boundaries are not defined, to get all the contents of the server response

Web_reg_save_param ("Fcontent", "lb=", "rb=", "Search=body", last);





/* Download Help file */



Lr_start_transaction ("Export file");

Request to send an export file

Web_url ("Downloadservlet", "Url= http://wenku.baidu.com/view/9052ad6c011ca300a6c39060.html", "resource=1", " Reccontenttype=application/x-msdownload "," referer= "," Snapshot=t41.inf ", last);

Lr_convert_string_encoding (Lr_eval_string ("{fcontent}"), Lr_enc_system_locale,lr_enc_utf8, "str");

Gets the length of the file in the response
Flen = Web_get_int_property (http_info_download_size);


strcpy (filepath,lr_eval_string ("d://data export {Num}.doc"));
if (Flen > 0) {

Open a file in write mode

if (Filedes = fopen (filepath, "wb") = = = NULL)

{

Lr_output_message ("Open file failed!");

return-1;

}

Write file contents

Fwrite (lr_eval_string ("{str}"), Flen, 1, filedes);

Close File

Fclose (Filedes);

}

Lr_end_transaction ("Export File", Lr_auto);

return 0;
}

LR File Download script (file parameterized rename)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.