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
: 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.
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.
>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.
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
"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.
--
As always, any help is much appreciated.
Regards,
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
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.
--