IT Community - Software Programming, Web Development and Technical Support

Download a file using Perl..

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> </...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Perl

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-18-2007, 03:45 AM
raj raj is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 89
raj is on a distinguished road
Default Download a file using Perl..

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
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 01:56 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0