473,243 Members | 1,599 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,243 software developers and data experts.

download-header not working in IE

Hi,

i try to give my script headers so the output text would be downloaded in
the client's browser and not displayed. But it doesn't work at all in my IE
6 and Opera.

<?
header("Content-Type: application/octet-stream");
header("Content-Length: 5");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"gamedata.txt\"");

echo "hello";
?>

I have an Apache 1 installed on my system, can it be that it is
misconfigured and sends the headers in a wrong way? How can i change this?

Help please,

bye,
Frank
Jul 17 '05 #1
18 13590
What error message do you get?

Also, recall that once the script sends any text, it cannot subsequently
send headers (PHP should complain about this if error reporting is not
turned off).

EE

----- Original Message -----
From: "Frank Thorstens" <Fr************@gmx.de>
Newsgroups: comp.lang.php
Sent: Wednesday, November 05, 2003 6:15 PM
Subject: download-header not working in IE

Hi,

i try to give my script headers so the output text would be downloaded in
the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera.

<?
header("Content-Type: application/octet-stream");
header("Content-Length: 5");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"gamedata.txt\"");

echo "hello";
?>

I have an Apache 1 installed on my system, can it be that it is
misconfigured and sends the headers in a wrong way? How can i change this?
Help please,

bye,
Frank


"Frank Thorstens" <Fr************@gmx.de> wrote in message
news:bo*************@ID-202045.news.uni-berlin.de... Hi,

i try to give my script headers so the output text would be downloaded in
the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera.

<?
header("Content-Type: application/octet-stream");
header("Content-Length: 5");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"gamedata.txt\"");

echo "hello";
?>

I have an Apache 1 installed on my system, can it be that it is
misconfigured and sends the headers in a wrong way? How can i change this?
Help please,

bye,
Frank

Jul 17 '05 #2
"Frank Thorstens" <Fr************@gmx.de> wrote in message news:<bo*************@ID-202045.news.uni-berlin.de>...
Hi,

i try to give my script headers so the output text would be downloaded in
the client's browser and not displayed. But it doesn't work at all in my IE
6 and Opera.

<?
header("Content-Type: application/octet-stream");
header("Content-Length: 5");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"gamedata.txt\"");

echo "hello";
?>

I have an Apache 1 installed on my system, can it be that it is
misconfigured and sends the headers in a wrong way? How can i change this?

Help please,


IE needs special headers. Read the notes at
http://in.php.net/header

<?php

header('Content-Type: XXXXXXXXXXXXXX');
//IE need specific header
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
header('Content-Disposition: inline; filename="'.$file_name.'"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else
{
header('Content-Disposition: attachment;
filename="'.$file_name.'"');
header('Pragma: no-cache');
}
?>
---
"The world is too dangerous to live in—not because of the people who
do evil, but because of the people who sit and let it happen"---Albert
Einstein
Email: rrjanbiah-at-Y!com
Jul 17 '05 #3
Hi,
i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in
my IE
6 and Opera.

What error message do you get?

Also, recall that once the script sends any text, it cannot subsequently
send headers (PHP should complain about this if error reporting is not
turned off).


I get no error, but it just shows the text in the browser.
I send the headers before any other output.

bye,
Frank
Jul 17 '05 #4
Hi,
i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera.

IE needs special headers. Read the notes at
http://in.php.net/header


Thanks, i tried your code but still no luck, the IE just shows the text in
the browser. :-(

bye,
Frank
Jul 17 '05 #5

On 5-Nov-2003, "Frank Thorstens" <Fr************@gmx.de> wrote:
i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera.

IE needs special headers. Read the notes at
http://in.php.net/header


Thanks, i tried your code but still no luck, the IE just shows the text in
the browser. :-(


Here's what works for me:
I can't remember where I got it, maybe here. :-)

$filename = $ex_name.'.csv';
$mime_type = 'text/x-csv';
header('Content-Type: ' . $mime_type);
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')!==false)
{
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else
{
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Pragma: no-cache');
}

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #6
Frank Thorstens wrote:
i try to give my script headers so the output text would be downloaded in
the client's browser and not displayed.


Why?

--
Jock
Jul 17 '05 #7
> > i try to give my script headers so the output text would be downloaded
in
the client's browser and not displayed.


Why?


The client have to open this file in excel. So it's more convinient if he
directly saves the data instead of seeing it in the browser, than have to
save it as text etc.

bye,
Frank
Jul 17 '05 #8
Frank Thorstens wrote:
The client have to open this file in excel. So it's more convinient if he
directly saves the data instead of seeing it in the browser, than have to
save it as text etc.


Why is the client limited to those options?

--
Jock
Jul 17 '05 #9
> > The client have to open this file in excel. So it's more convinient if
he
directly saves the data instead of seeing it in the browser, than have to save it as text etc.


Why is the client limited to those options?


not sure, if I understand your question. The user on the client side wants
to put the downloaded Data into an excel sheet. So it's more convinient if
he directly saves the file and open it in excel.

bye,
Frank
Jul 17 '05 #10
Frank Thorstens wrote:
The user on the client side wants to put the downloaded Data into an excel
sheet.
What format is the data in?
So it's more convinient if he directly saves the file and open it in excel.


If it's an Excel spreadsheet, the registered MIME media type is
application/vnd.ms-excel.

--
Jock
Jul 17 '05 #11
> > The user on the client side wants to put the downloaded Data into an
excel
sheet.

What format is the data in?


it's a comma-separated text file.
The MIME for comma-separeted text files also didn't work. I found out, what
was wrong, see the other post.

but thanks for replying,
Frank
Jul 17 '05 #12
ok, i tested always by putting the URL of the PHP page into the address
field of the browser.
I now found, that the download is initiated by a href to the page or by
other way of linking.

So it seems to work.

Thank all you guys for replying.

bye,
Frank
Jul 17 '05 #13
Frank Thorstens wrote:
it's a comma-separated text file.
The MIME for comma-separeted text files also didn't work.


There is no registered MIME media type for that format. You
might've used text/x-csv or suchlike. Whatever you use, the major
type should be text.

--
Jock
Jul 17 '05 #14
"Frank Thorstens" <Fr************@gmx.de> wrote in message news:<bo*************@ID-202045.news.uni-berlin.de>...
Hi,
i try to give my script headers so the output text would be downloaded in the client's browser and not displayed. But it doesn't work at all in my IE 6 and Opera.

IE needs special headers. Read the notes at
http://in.php.net/header


Thanks, i tried your code but still no luck, the IE just shows the text in
the browser. :-(


In my experience, it won't download if you call it directly.
But, it will work if you call from another script by clicking or by
POST or GET.

---
"The world is too dangerous to live in—not because of the people who
do evil, but because of the people who sit and let it happen"---Albert
Einstein
Email: rrjanbiah-at-Y!com
Jul 17 '05 #15
*** Frank Thorstens wrote/escribió (Thu, 6 Nov 2003 00:15:46 +0100):
i try to give my script headers so the output text would be downloaded in
the client's browser and not displayed. But it doesn't work at all in my IE
6 and Opera.
Your code works for me under Internet Explorer 6. However, it claims it's a
text plain file: IE ignores Content-Type header under certain circumstances
in favour of file extension. That means IE probably makes this a Windows
configuration issue: if you have the "*.txt" file type configured as
"Confirm opening after download" (words might differ, I'm translating from
Spanish) IE will prompt; otherwise, it'll open it inline.

<?
header("Content-Type: application/octet-stream");
header("Content-Length: 5");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=\"gamedata.txt\"");

echo "hello";
?>

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #16
ng**********@rediffmail.com (R. Rajesh Jeba Anbiah) wrote in message news:<ab**************************@posting.google. com>...
"Frank Thorstens" <Fr************@gmx.de> wrote in message news:<bo*************@ID-202045.news.uni-berlin.de>...
Hi,
> i try to give my script headers so the output text would be downloaded in > the client's browser and not displayed. But it doesn't work at all in my IE > 6 and Opera.
IE needs special headers. Read the notes at
http://in.php.net/header


Thanks, i tried your code but still no luck, the IE just shows the text in
the browser. :-(


In my experience, it won't download if you call it directly.
But, it will work if you call from another script by clicking or by
POST or GET.


Frank! Could you please confirm, if it works while calling from
another script or after a POST/GET..

---
"Learn from yesterday, live for today, hope for tomorrow. The
important thing is to not stop questioning."---Albert Einstein
Email: rrjanbiah-at-Y!com
Jul 17 '05 #17
> Frank! Could you please confirm, if it works while calling from
another script or after a POST/GET..


Hi, yes it works, i wrote this as answer to a parallel branch of this
thread. Thanks for your hint!

bye,
Frank
Jul 17 '05 #18
"Frank Thorstens" <Fr************@gmx.de> wrote in message news:<bo*************@ID-202045.news.uni-berlin.de>...
Frank! Could you please confirm, if it works while calling from
another script or after a POST/GET..


Hi, yes it works,


Ok fine. Thanks for acknowledging.

---
"Learn from yesterday, live for today, hope for tomorrow. The
important thing is to not stop questioning."---Albert Einstein
Email: rrjanbiah-at-Y!com
Jul 17 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sarah Akers | last post by:
GgF ----gL5cJ72EqiGIQ0SK65Rz Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html> <head> <style type=3D"text/css">.eyebrow { FONT-WEIGHT: bold; FONT-SIZE: 10px; TE=
0
by: jmd | last post by:
Hello. I want to write a C# program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6) 2. I browse to my desired download page, say...
1
by: Al | last post by:
Hi! I try to use custom download page (download.aspx) wich writes file (about 700Mb) to response. But I can download only one file from one IP at the same time. I think that this is IIS or...
0
by: Rhys666 | last post by:
Basically I have a link that opens my download page and the querystring identifies the type of 'template' Excel spreadsheet has asked to download. The download page reads the querystring,...
3
by: Nathan Sokalski | last post by:
I have a webform that contains a button which I want to do three things: 1. Delete a record from a database 2. Let the user download a text file that is generated 3. Refresh the page to show...
18
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does...
1
by: JayLembeck | last post by:
Over 50,000 Free Ringtone. Get the Latest Ringtone. Download now- Fast, Free and Easy. Get your FREE surprise RINGTONE now! http://seekoutfast.info/free-ringtone/ free ringtone free ringtone new...
5
by: Khafancoder | last post by:
Hi guys, i am building a FileSharing website, i wanna allow users to be able using download managers such as DAP to download files from webserver but don't allow them to retrive files url......
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

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.