473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Need to download file based on user input

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(fatalsToBrowser);

my $files_location;
my $ID;
my @fileholder;
my $first = $cgi->param('first_name');
my $last = $cgi->param('last_name');


print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Generating Self-Referential URLs</title></head>
<body>
<FORM action="Maintenance_Data.cgi" method="POST">
Circle: <input type="text" name="first_name"> <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:attachment;filename=$ID\r\n\n";
open(FIL,"<$fileloc") || die "Cannot open $filename, $!";
while (<FIL>) { print $_; }
close(FIL);

}
Jul 3 '19 #1
0 3571

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tom | last post by:
Hi, I have a website providing pdf file downloading for registered member. Member needs to login and be able to download pdf file. I save pdf file in a directory. e.g....
1
by: Ani | last post by:
Hi, I need to carry the user input across pages and then at the end insert all the values into the DB. How do I best accomplish this task in ASP.Net. I am a novice , please give me some simple...
7
by: Daniel Walzenbach | last post by:
Hello, I want to create a Word XML file based on the input users make in a VB.NET application. I imagine creating a template in Word and saving it as a XML file. I then want to fill the...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
10
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go...
2
by: ch68813 | last post by:
I'm making a program that asks for an item number and if it matches an item number in the text file it will then determine its next move by what variable is displayed on the line that the item number...
4
by: myself2211 | last post by:
Hi, this is my first attempt at Python, what I am trying to achieve is a script that will ask the user for input, search a txt file and display the output or give not found message. Ideally I would...
1
by: golnaz hgh | last post by:
the xml file is like this: <publist> <book> A book entry has the following fields: o Title; o One or more authors; o Publisher; o Year </book>
8
by: thomashurlburt | last post by:
i can't seem to get my program to save the Set.savv file and encrypt it and decrypt it when user logs back on to there virtual file on a CD and writing it to the disk its self and closing the session
0
by: vysakhv90 | last post by:
Hi, This may be the easiest question you have ever heard..But I must ask this since I am new to Powershell.. I need powershell to ask for a user input and then based on the input it must read the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.