Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File download and IE

16 views
Skip to first unread message

webcon...@yahoo.com

unread,
Apr 14, 2005, 5:58:27 PM4/14/05
to
Hello All,

I am pretty new to CGI scripting. I have written little script which
downloads the file from the server. The script runs fine with Netscape
and FireFox browsers, but IE is not behaving right. Basically, instead
of popping a dialouge box to save the file, IE prints the contents on
the browser. Here is what I have:

printf("<Content-type: text/html; charset=UTF-8\n\n>"\
"<html>\n<head>\n<title>\n</title>\n"
"</head>\n<body>");
printf("<Content-Type:application/x-download;\n>"\
"<Content-length: %u;\n>"\
"<Content-Disposition:attachment;filename=test;\n\n>",
l_dump_len);

Note: On Netscape and FireFox, I get the download box and everything is
okay.

Any help, hint, suggesstion would be much appreciated.

Regards,


--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html

Malcolm Dew-Jones

unread,
Apr 14, 2005, 7:57:10 PM4/14/05
to
webcon...@yahoo.com (webcon...@yahoo.com) wrote:
: Hello All,

: I am pretty new to CGI scripting. I have written little script which
: downloads the file from the server. The script runs fine with Netscape
: and FireFox browsers, but IE is not behaving right. Basically, instead
: of popping a dialouge box to save the file, IE prints the contents on
: the browser. Here is what I have:

: printf("<Content-type: text/html; charset=UTF-8\n\n>"\
: "<html>\n<head>\n<title>\n</title>\n"
: "</head>\n<body>");
: printf("<Content-Type:application/x-download;\n>"\
: "<Content-length: %u;\n>"\
: "<Content-Disposition:attachment;filename=test;\n\n>",
: l_dump_len);

If you run the above then the header says content-type: text/html, in
which case the browser should display it.

Perhaps you only run the second printf? Older IE's examine the extension
of the filename of the original query string (or some such thing) to
determine how to handle the download. In that case you need to play with
the file names in the original query and possibly in the download filename
to get IE to prompt to save the file. I'm sure that many tricks to make
IE work have ben posted before, but one such trick is to create your cgi
script with a name like "download.dat" and tell the web server to allow
that name as a cgi file. (instead of a name like download.cgi).

The newest versions of IE may be fixed (for this issue at least, not for
others of course).

--

This space not for rent.

webcon...@yahoo.com

unread,
Apr 14, 2005, 7:04:12 PM4/14/05
to
Malcolm,
Thanks for the quick response.

There was a typo in my original query. I don't have first block of
print statement. What I have is only this:


printf("<Content-Type:application/x-download;\n>"\
"<Content-length: %u;\n>"\
"<Content-Disposition:attachment;filename=test;\n\n>",
l_dump_len);

However, I will now try with various file extensions to see if that
helps.

Once again, thanks for your quick response.

Si Ballenger

unread,
Apr 14, 2005, 8:01:07 PM4/14/05
to
On 14 Apr 2005 15:57:10 -0800, yf...@victoria.tc.ca (Malcolm
Dew-Jones) wrote:

>webcon...@yahoo.com (webcon...@yahoo.com) wrote:
>: Hello All,
>
>: I am pretty new to CGI scripting. I have written little script which
>: downloads the file from the server. The script runs fine with Netscape
>: and FireFox browsers, but IE is not behaving right. Basically, instead
>: of popping a dialouge box to save the file, IE prints the contents on
>: the browser. Here is what I have:
>
>: printf("<Content-type: text/html; charset=UTF-8\n\n>"\
>: "<html>\n<head>\n<title>\n</title>\n"
>: "</head>\n<body>");
>: printf("<Content-Type:application/x-download;\n>"\
>: "<Content-length: %u;\n>"\
>: "<Content-Disposition:attachment;filename=test;\n\n>",
>: l_dump_len);
>
>If you run the above then the header says content-type: text/html, in
>which case the browser should display it.

I think the first line should be seperated from the html with one
line. You might try charset=UTF-8\n>"\ with one n\ instead of
two.

webcon...@yahoo.com

unread,
Apr 15, 2005, 11:23:20 AM4/15/05
to
Okay .. so here I am .. I tried the following code and it has two
problems
print ("<Content-Disposition:attachment;filename=%s\n"\
"<Content-length: %u\n>"\
"<Content-Type:application/x-download\n\n>", "test.dat",
size);

Problems are:
1. Firefox and Netscape prompt me to download the file but don't use my
suggested name, test.dat
2. IE doesn't prompt to download the file and it prints the contents on
the browser.

any idea? .. I know it is in the header and the way it needs to be
populated but I can't seem to find that information yet.

Thank you all for your input

Regards

Malcolm Dew-Jones

unread,
Apr 15, 2005, 1:34:11 PM4/15/05
to
webcon...@yahoo.com (webcon...@yahoo.com) wrote:
: Okay .. so here I am .. I tried the following code and it has two

: problems
: print ("<Content-Disposition:attachment;filename=%s\n"\
: "<Content-length: %u\n>"\
: "<Content-Type:application/x-download\n\n>", "test.dat",
: size);


"print" ? Do you mean "printf"

I believe the headers need one space after the colon, as shown below, and
one space after the ; might be needed (not sure).

: print ("<Content-Disposition: attachment; filename=%s\n"\
^^^ ^^^
: "<Content-length: %u\n>"\


: "<Content-Type: application/x-download\n\n>", "test.dat",

^^^

I think the Content-Type headers is also able to have a name= parameter,
and some examples of downloading show that, perhaps that would make a
difference.

And for older IE, as I said, the file name seen _in_the_link_ to this code
makes a difference. That name has never been shown here so I can't
comment on it.


Beyond that, I don't have more to say.

--

This space not for rent.

--

webcon...@yahoo.com

unread,
Apr 15, 2005, 2:53:25 PM4/15/05
to
I tried every possible variation of the header .. I tried inserting
spaces as suggested above. But nothing is working.. I am still not able
to use my given file name on Firefox and Netscape browsers. And IE
still doesn't prompt for file download. I am using IE v 6.0 so the
older version problem is out of the question

As always, any help is much appreciated.

Regards,

Sherm Pendley

unread,
Apr 15, 2005, 3:06:12 PM4/15/05
to
webcon...@yahoo.com wrote:
> Okay .. so here I am .. I tried the following code and it has two
> problems
> print ("<Content-Disposition:attachment;filename=%s\n"\
> "<Content-length: %u\n>"\
> "<Content-Type:application/x-download\n\n>", "test.dat",
> size);

Why are you putting angle brackets around HTTP headers?

> Problems are:
> 1. Firefox and Netscape prompt me to download the file but don't use my
> suggested name, test.dat
> 2. IE doesn't prompt to download the file and it prints the contents on
> the browser.
>
> any idea?

Google for "Content-Disposition Internet Explorer". This is very well
covered ground.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

webcon...@yahoo.com

unread,
Apr 15, 2005, 4:10:51 PM4/15/05
to
I have removed those angel brackets but the problem remains the same. I
even gave .bin file extension, but nothing seems to be working.

Malcolm Dew-Jones

unread,
Apr 15, 2005, 6:22:56 PM4/15/05
to
webcon...@yahoo.com (webcon...@yahoo.com) wrote:
: I tried every possible variation of the header .. I tried inserting

: spaces as suggested above. But nothing is working.. I am still not able
: to use my given file name on Firefox and Netscape browsers.

originally you said

:Note: On Netscape and FireFox, I get the download box and everything is
:okay.

so how come that's broken now? I think something else must have gotten
bodged in your fiddling. Perhaps it's time start to stand back and start
over with different files and paths. Create a minimal script that
downloads a static set of 500 bytes of zeros and ones that works on
Netscape and FireFox, and use that as a starting point for any other
changes.


$0.02

--

This space not for rent.

--

0 new messages