Hello ,
I need to download file from the server based on user inputs.
Suppose user give the input Gabon and Core,the file name which should get downlaoded will be Gabon_Core.csv.
I tried to create below code for the same but somehow it is not working.Any help will be highly appreciated.
#!/usr/bin/perl
use CGI ':standard';
use CGI::Carp qw(fatalsToBrow ser);
my $files_location ;
my $ID;
my @fileholder;
my $first = $cgi->param('first_n ame');
my $last = $cgi->param('last_na me');
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><ti tle>Generating Self-Referential URLs</title></head>
<body>
<FORM action="Mainten ance_Data.cgi" method="POST">
Circle: <input type="text" name="first_nam e"> <br>
Technology: <input type="text" name="last_name ">
<input type="submit" value="Submit">
</FORM>
<p>The name you entered was '$first $last'</p>
<p>The name you entered was '$file'</p>
</body>
EndOfHTML
$files_location = "/opt/IBM/netcool/gui/omnibus_webgui/etc/cgi-bin/";
#$ID = param('file');
$ID = $first . '_' . $last . '_csv';
$ID = "Gabon_Core.csv ";
#print "Content-type: text/html\n\n";
#print "ID =$ID";
if ($ID eq '') {
print "You must specify a file to download.";
} else {
$fileloc=$files _location . $ID;
print "Content-Type:text/csv\n";
print "Content-Disposition:att achment;filenam e=$ID\r\n\n";
open(FIL,"<$fil eloc") || die "Cannot open $filename, $!";
while (<FIL>) { print $_; }
close(FIL);
}
I need to download file from the server based on user inputs.
Suppose user give the input Gabon and Core,the file name which should get downlaoded will be Gabon_Core.csv.
I tried to create below code for the same but somehow it is not working.Any help will be highly appreciated.
#!/usr/bin/perl
use CGI ':standard';
use CGI::Carp qw(fatalsToBrow ser);
my $files_location ;
my $ID;
my @fileholder;
my $first = $cgi->param('first_n ame');
my $last = $cgi->param('last_na me');
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><ti tle>Generating Self-Referential URLs</title></head>
<body>
<FORM action="Mainten ance_Data.cgi" method="POST">
Circle: <input type="text" name="first_nam e"> <br>
Technology: <input type="text" name="last_name ">
<input type="submit" value="Submit">
</FORM>
<p>The name you entered was '$first $last'</p>
<p>The name you entered was '$file'</p>
</body>
EndOfHTML
$files_location = "/opt/IBM/netcool/gui/omnibus_webgui/etc/cgi-bin/";
#$ID = param('file');
$ID = $first . '_' . $last . '_csv';
$ID = "Gabon_Core.csv ";
#print "Content-type: text/html\n\n";
#print "ID =$ID";
if ($ID eq '') {
print "You must specify a file to download.";
} else {
$fileloc=$files _location . $ID;
print "Content-Type:text/csv\n";
print "Content-Disposition:att achment;filenam e=$ID\r\n\n";
open(FIL,"<$fil eloc") || die "Cannot open $filename, $!";
while (<FIL>) { print $_; }
close(FIL);
}