tanuj has asked for the wisdom of the Perl Monks concerning the following question:
Need some cgi-perl script which can download a file form server machine. EX: click on a download link and it will open a save as window and will allow me to same the file on my local machine.
i have created a web page using CGI , using this i will upload a file to server and will run a perl script to convert it to some other format ( till here i am done) Now i need get this file back ( download back ) the the system.
Re: Perl CGI to download files via web browser
by marto (Cardinal) on Mar 08, 2013 at 13:47 UTC
|
You mean the part you're stuck on is where you upload the file from a client machine back to the server? Your question could use some clarification, and you could show us the code you're actually working on/having problems with, How do I post a question effectively?.
| [reply] |
|
Thanks for the reply.
there are three steps :
1. upload a file from my machine ( client ) to server machine using CGI -> i am done with this part.
2. convert the uploaded file to the required format -> i am done with this part too.
3. Now the converted file is under some dir of server machine , now i want to get ( downlaod ) this file back to may local machine ( client ) -> i am stuck in this part.
| [reply] |
|
One solution would be to load the file contents into memory and serve the content with the appropriate header. This of course depends on the size of the file, you don't want to load large files into memory and serve it like this. You could copy the file into a temporary web accessable area and provide a link to it. Other things to consider, do you want to remove the converted file after you've sered it, so that you don't end up filling some filesystem with old files people have downloaded? Perhaps you'd need to write a housekeeping script to tidy up these files/areas on a regular basis. Clarify your requirements and consider the implications of your system. See also Print to Browser Headers Not Working Serve a file from a CGI script.
| [reply] |
|
|
|
|