Save data from a CGI program to a file

A

Angus

Hello

I have a server product with an embedded web (hhtp) server. Settings
relating to the server are stored in text config files on the server.
I want to be able to make a backup of these files to a users hard
drive via their web briwser. ie the user clicks on a backup button to
save the config to a text file on the users hard drive.

I can program the CGI program to send the relevant text. But how
would I intercept this text and save as a text file on the users hard
drive? I assume this can be done using JavaScript? I also need the
Save As dialog to display so user can select folder to save file and
give file a name.

I guess Javascript can do this because I have a Netgear router and it
has a Backup button. If I click on the Backup button I get prompted
with a 'Do you want to save this file' dialog. If I click Save button
I can change the default name of the file and change the location to
save to.

That is basically the functionality I need? How?

Any help would be very much appreciated.

Angus
 
B

Bart Van der Donck

Angus said:
I have a server product with an embedded web (hhtp) server.  Settings
relating to the server are stored in text config files on the server.
I want to be able to make a backup of these files to a users hard
drive via their web briwser.  ie the user clicks on a backup button to
save the config to a text file on the users hard drive.

I can program the CGI program to send the relevant text.  But how
would I intercept this text and save as a text file on the users hard
drive?  I assume this can be done using JavaScript?  I also need the
Save As dialog to display so user can select folder to save file and
give file a name.

I guess Javascript can do this because I have a Netgear router and it
has a Backup button.  If I click on the Backup button I get prompted
with a 'Do you want to save this file' dialog.  If I click Save button
I can change the default name of the file and change the location to
save to.

That is basically the functionality I need?  How?

No javascript needed. You appear to have a whole bunch of files; I
would go for a zip-operation at the server and then offer it from the
CGI with header 'Content-Type: application/zip'. For added
reliability, you could also rename the CGI script to a .zip extension,
and make your webserver execute .zip as CGI (rule 'AddHandler cgi-
script .zip' in Apache's conf file or .htaccess).

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top