Solved

How to start a file download using CGI?

Posted on 1997-11-08
4
324 Views
Last Modified: 2013-12-25
I am trying to implement a single HTML Web page at my Web site that performs two actions:

1) Prompt the visitor for their email address and then...

2) Start a download of a specific .ZIP file


I have a form on a Web page (example):

<form
action="https://www.mysite.com/myaccount/cgibin/download.cgi"
method="POST">
<input type="hidden" name="THISPROGRAM" value="DOWNLOAD">

<input type="text" size="30" name="address">
</form>

...and I know enough about CGI/Perl to be dangerous.  The current CGI script
I use can retrieve the email "address" input from this form and use it. This is no problem.  I am fine here.  However, my problem is I don't know how a CGI script can initiate a file transfer, in this case MYPROG.ZIP
located at:   www.mysite.com/pub/myprog.zip to the visitor's browser.

I wish that a form action could run TWO commands at the same time, but I fear that this is not possible, therefore I must initiate the file download/transfer from the cgi script (which I don't know how to do).

Any suggestions and examples would be greatly appreciated.
0
Comment
Question by:Kapusta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:Kapusta
ID: 1831118
Edited text of question
0
 

Author Comment

by:Kapusta
ID: 1831119
Adjusted points to 150
0
 

Author Comment

by:Kapusta
ID: 1831120
Adjusted points to 250
0
 
LVL 6

Accepted Solution

by:
alamo earned 250 total points
ID: 1831121
This is done via a redirect, i.e. your perl script would write as the only header:

print "Location: http://www.mysite.com/pub/myprog.zip\n\n";

This will send a signal to the browser which will turn around and get the file. The only drawback is the user will be left looking at the page with the original form, you can't send the suer another message. On the plus side though,  the URL of the file won't show on the Location: line.

Does this meet your needs? If not, leave a comment and I'll change it... good luck!

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
powershell code to list items in dropdown 6 113
How can i open a .fxp file 3 66
Ruby or Python 7 130
Testing site for http code 200 or curl equiv for Windows 2 98
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question