Add Seperate MD5 File of CSV Download

Questions related to customising nuBuilder Forte with JavaScript or PHP.

Add Seperate MD5 File of CSV Download

Unread postby pmjd » Fri Oct 29, 2021 1:26 am

Does anyone know how you can add to the "Download to CSV" code in the nuBuilder Code Library so that you also get an additional file that contains the MD5 value for the CSV file?

Thanks,
Paul
pmjd
 
Posts: 110
Joined: Fri Mar 12, 2021 7:08 pm
nuBuilder Version: 4.5

Re: Add Seperate MD5 File of CSV Download

Unread postby kev1n » Fri Oct 29, 2021 2:18 am

I think you'll have to save the file to the server first and calculate its md5. Then write it to a file and download both files to the browser.

Instead of
Code: Select all
$fp = fopen('php://output', 'w');


you would write it to a file on the server
Code: Select all
$fp = fopen('something.csv', 'w');


Then after fclose($fp) use md5_file() to retrieve its md5.

Use fwrite() etc. to write it to a file.

Finally, download both files (example)
kev1n
nuBuilder Team
 
Posts: 2135
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Add Seperate MD5 File of CSV Download

Unread postby pmjd » Fri Oct 29, 2021 7:17 pm

Thanks kev1n, will have a look and see what I can work out.
pmjd
 
Posts: 110
Joined: Fri Mar 12, 2021 7:08 pm
nuBuilder Version: 4.5

Re: Add Seperate MD5 File of CSV Download

Unread postby kev1n » Thu Nov 11, 2021 5:47 pm

Hi Paul,

Were you able to make it work?
kev1n
nuBuilder Team
 
Posts: 2135
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5


Return to Custom Code

Who is online

Users browsing this forum: No registered users and 10 guests