This is a discussion on Download a file using Perl.. within the Perl forums, part of the Software Development category; 1. front end html page: ---------------------------------------------- <html><head> <title>Download Page</title> </...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 1. front end html page: ---------------------------------------------- <html><head> <title>Download Page</title> </head> <body> <form action="download_script.cgi"> <p> <select size="1" name="ID"> <option value="CallMe.png">File One </option> <option value="AngelSkype.png">File Two </option> </p> </select> <input type="submit" value="Submit" name="B1"> </form> </body> </html> 2. download_script.cgi -------- download function here #!/usr/bin/perl -wT use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); my $files_location; my $ID; my @fileholder; $files_location = "images"; $ID = param('ID'); if ($ID eq '') { print "Content-type: text/html\n\n"; print "You must specify a file to download."; } else { open(DLFILE, "<$files_location/$ID") || Error('open', 'file'); @fileholder = <DLFILE>; close (DLFILE) || Error ('close', 'file'); print "Content-Type:application/x-download\n"; print "Content-Disposition:attachment;filename=$ID\n\n"; print @fileholder } |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Run PERL file in web brower ? | priyan | Server Management | 1 | 08-07-2007 12:48 AM |
| Info: File Upload using Perl | raj | Perl | 0 | 07-23-2007 06:00 AM |
| What is the easiest way to download the contents of a URL with Perl? | sivaramakrishnan | Perl | 1 | 07-23-2007 04:38 AM |
| File Download From a URL | moinuddin102 | PHP Programming | 1 | 05-01-2007 06:51 AM |
| File download status | JSureshkumar | ASP and ASP.NET Programming | 1 | 03-22-2007 08:22 AM |