Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Downloading data to file

Status
Not open for further replies.

duffs

Programmer
Sep 22, 2000
48
US
Hi,

I have a perl script that I downloaded from the web. It allows the user to download data from a mysql file as a .CSV file.

Here's the problem. When I run it using IE on an XP PC, I am prompted to save the file. But when my customer runs it, it never prompts him. Instead it shows all the data in his browser. If he does File/Save as, it put quotes around the data in the text file, so that trying to open it in Excel doesn't parse it.

He is also on an XP PC running IE.

Is this a setting in his browser somewhere? Or is there something I can do differently in my Perl script so that it will definitely prompt him to save the file without showing him the data in his browser?

TIA

Here's the script. The ECSV script simple returns a collection of the data in the file you've passed to it.

#!/usr/bin/perl
use strict;
use ECSV;
my $this_csv;

my $csv= new ECSV;

$this_csv=$csv->serve("customers", $database, $host, $user, $pass,"freeEmailIssueSentDate is not null");
print "Content-Type: application/msexcel\n";
print "Content-disposition: inline; filename=\"somefile.csv\"\n\n";
print ($this_csv);
exit;
 
Well the Content-Type is telling the browser that it's getting an Excel file so IE is trying to help. You may want to set the content type to text/plain and setting a header to define an attachment.

I assume from what you say that you don't have Excel installed on your machine.

Hope that helps.

 
Another option would be to use the content-type of octet-stream. This will force the browser to just give a save dialog box.

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top