Re: [PHP] Downloading a file

2008-07-16 Thread Tom Chubb
On 16/07/2008, Robbert van Andel [EMAIL PROTECTED] wrote:

 I am having trouble getting a file to download to work in Internet
 Explorer.
 The site works fine in FireFox.   The page retrieves the contents of a file
 from a database and outputs the following



 ?PHP



 header(Content-type: application/octet-stream);

 header(Content-Disposition: attachment;
 filename=\{$data['filename']}\);

 header(Content-Description: PHP Generated Data);

 echo $data['file'];



 ?



 Where $data['filename'] is the name of the file as stored in the database
 and $data['file'] is the contents of the file.  The script used to download
 the file is called view.php.  As I mentioned, this works great in FireFox
 but with Internet Explorer, I get the following error:



 Internet Explorer cannot download view.php from www.yourdomain.com.



 Internet Explorer was not able to open this Internet site. The requested
 site is either unavailable or cannot be found. Please try again later.



 Any help would be greatly appreciated.



 Robbert


Start here:
http://www.google.co.uk/search?source=ighl=enrlz=q=php+download+file+internet+explorer+headersmeta
=


RE: [PHP] Downloading a file

2008-07-16 Thread Robbert van Andel
Thanks, that did the trick.  I'd done a google search before but didn't come
up with any answers but hadn't added headers to the search phrase.

 

In case anyone is interested in the solution, my script included
session_start and I found that by adding session_cache_limiter(none)
before session_start resolved the problem
(http://bytes.com/forum/thread554529.html) 

 

Robbert

 

From: Tom Chubb [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 16, 2008 1:41 AM
To: Robbert van Andel
Cc: php-general@lists.php.net
Subject: Re: [PHP] Downloading a file

 

On 16/07/2008, Robbert van Andel [EMAIL PROTECTED] wrote: 

I am having trouble getting a file to download to work in Internet Explorer.
The site works fine in FireFox.   The page retrieves the contents of a file
from a database and outputs the following



?PHP



header(Content-type: application/octet-stream);

header(Content-Disposition: attachment; filename=\{$data['filename']}\);

header(Content-Description: PHP Generated Data);

echo $data['file'];



?



Where $data['filename'] is the name of the file as stored in the database
and $data['file'] is the contents of the file.  The script used to download
the file is called view.php.  As I mentioned, this works great in FireFox
but with Internet Explorer, I get the following error:



Internet Explorer cannot download view.php from www.yourdomain.com.



Internet Explorer was not able to open this Internet site. The requested
site is either unavailable or cannot be found. Please try again later.



Any help would be greatly appreciated.



Robbert


Start here:

http://www.google.co.uk/search?source=ig
http://www.google.co.uk/search?source=ighl=enrlz=q=php+download+file+int
ernet+explorer+headersmeta
hl=enrlz=q=php+download+file+internet+explorer+headersmeta=



Re: [PHP] downloading a file using headers

2003-07-30 Thread CPT John W. Holmes
 I have a page that queries the database then uses the data to build an
 excel spreasheet.  THat spreadsheet is downloaded according to info in the
 headers.  My manager wants to put the page inside of another HTML page to
 make it prettier, but then it breaks because headers are already written
 (it's included in the other HTML page).  It works fine on it's own, but
 he really wants it in that page.  He wants to know if there is a
 way to trick it into working.

Just set a flag on whether you send the headers or not. Have it default to
sending them...

if(!isset($somevariable))
{ header(...); }

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] downloading a file using headers

2003-07-30 Thread Curt Zirzow
* Thus wrote Amanda McComb ([EMAIL PROTECTED]):
 I have a page that queries the database then uses the data to build an
 excel spreasheet.  THat spreadsheet is downloaded according to info in the
 headers.  My manager wants to put the page inside of another HTML page to
 make it prettier, but then it breaks because headers are already written
 (it's included in the other HTML page).  It works fine on it's own, but
 he really wants it in that page.  He wants to know if there is a
 way to trick it into working.

If I understand this corretly you want the page to be like:

   [html stuff]
   [excel spreadsheet]
   [html stuff]

The only way to do this is using iframes or somthing  similar to
that. You dont have to touch your php script at all.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] downloading a file using headers

2003-07-30 Thread Jason Sheets
You could use an iframe or you could turn on output buffering, when 
output buffering is enabled you can send headers after normal output has 
been sent.  Just do ob_start(); at the top of your script.  Not the most 
elegant way of doing it but it would work and not require you to use an 
iframe.

Jason

Amanda McComb wrote:

I have a page that queries the database then uses the data to build an
excel spreasheet.  THat spreadsheet is downloaded according to info in the
headers.  My manager wants to put the page inside of another HTML page to
make it prettier, but then it breaks because headers are already written
(it's included in the other HTML page).  It works fine on it's own, but
he really wants it in that page.  He wants to know if there is a
way to trick it into working.
Any ideas?  I can post the code if necessary, but it's lng and messy.

THanks,
Amanda
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Downloading a file.

2003-06-12 Thread Dustin Pate

Jeff Harris [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Jun 11, 2003, Alex Earl claimed that:

 | Does anyone know what to do to make it saved as: mysoft-1.0-truc.zip
 |
 | And I would like to display a page telling Thanks for download or
 | something...but if I had to the end:
 | header(Location: http://www.mywebsite.com/thanks.html;) ;
 | I does not work :(

 header(Location:...); must not be sent after any html, so you won't be
 able to redirect that way.

 Perhaps if you know approximately how much time it takes to download the
 file, you can use a meta http-equiv=refresh... to redirect to a
 thanks for downloading page, with a link back to the download.


Better yet, can you not spawn the download off in another window, which will
be closed automatically when it's discovered to be a file download instead,
and then do what ever you want in the main browser window?

Dustin Pate



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Downloading a file.

2003-06-11 Thread Alex Earl

 If he wants to download, in the file downloadit.php, there is:
 header(Content-type: application/octet-stream\n);
 header(Content-Disposition: attachment; filename=mysoft-1.0-truc.zip);
 header('Cache-Control: public');
 header(Content-transfer-encoding: binary\n);
 header(Content-length:  . filesize($path) . \n);
 $fp=fopen($path, r);
 fpassthru($fp);

 But, with IE, it saves the file with [] as:
 mysoft-1.0[1]-truc.zip
 And with Netscape 7.x, it saves the file with the .php extension:
 mysoft-1.0-truc.zip.php

 Does anyone know what to do to make it saved as: mysoft-1.0-truc.zip

 And I would like to display a page telling Thanks for download or
 something...but if I had to the end:
 header(Location: http://www.mywebsite.com/thanks.html;) ;
 I does not work :(

 Does anyone know how change the location and is there is anyway to know
 if the download has been perfomed 'till the end...

 Thanks,
 Vincent.

There is no way to tell if the download completes, I don't think, that is
a client side thing that if you send the content-length header it should
know if the file downloaded successfully or not, the browser does not send
a success signal back. Also, if you put quotes around the filename in
the Content-Disposition header, it will save the file with the exact
filename you specify, the RFC doesn't specifiy that it has to be this way,
but I have found that putting quotes around it makes it work for pretty
much any browser I have tried.

For your other problems, I would deconstruct them one by one and try and
get a piece of it working and then put the pieces together, it sounds like
you are trying to get too much done in one pass and it is causing you
problems.

Cheers,

Slide

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Downloading a file.

2003-06-11 Thread Jeff Harris
On Jun 11, 2003, Alex Earl claimed that:

|
| If he wants to download, in the file downloadit.php, there is:
| header(Content-type: application/octet-stream\n);
| header(Content-Disposition: attachment; filename=mysoft-1.0-truc.zip);
| header('Cache-Control: public');
| header(Content-transfer-encoding: binary\n);
| header(Content-length:  . filesize($path) . \n);
| $fp=fopen($path, r);
| fpassthru($fp);
|
| But, with IE, it saves the file with [] as:
| mysoft-1.0[1]-truc.zip
| And with Netscape 7.x, it saves the file with the .php extension:
| mysoft-1.0-truc.zip.php
|
That seems to be a Netscape/Mozilla feature. It seems to always save the
file with the source file's extension. I have the same issue sending a
data that should be a .csv file ending up as a .csv.cgi.


| Does anyone know what to do to make it saved as: mysoft-1.0-truc.zip
|
| And I would like to display a page telling Thanks for download or
| something...but if I had to the end:
| header(Location: http://www.mywebsite.com/thanks.html;) ;
| I does not work :(

header(Location:...); must not be sent after any html, so you won't be
able to redirect that way.

|
| Does anyone know how change the location and is there is anyway to know
| if the download has been perfomed 'till the end...
|
| Thanks,
| Vincent.
|
|There is no way to tell if the download completes, I don't think, that is
|a client side thing that if you send the content-length header it should
|know if the file downloaded successfully or not, the browser does not send
|a success signal back. Also, if you put quotes around the filename in
|the Content-Disposition header, it will save the file with the exact
|filename you specify, the RFC doesn't specifiy that it has to be this way,
|but I have found that putting quotes around it makes it work for pretty
|much any browser I have tried.
|

Perhaps if you know approximately how much time it takes to download the
file, you can use a meta http-equiv=refresh... to redirect to a
thanks for downloading page, with a link back to the download.

Jeff
-- 
Registered Linux user #304026.
lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] downloading XML file

2003-06-03 Thread Marek Kilimajer
header('Content-type: application/octet-stream');

Sichta Daniel wrote:
Hi,

cfg: php 4.2.3, IIS5.1

I have generated link (from MySQL database) on my web sile, which suppose to
allow user to dowload xml file. How can I do this because when I'm just
adding name of the file to the href then it will be open in Browser window.
How can I make the browser open the oepn or save dialog window ?
THX

PS: I think it has something to do with html header !!

Ing. Daniel ichta
EIF AS TIS
Siemens Program and System Engineering s.r.o.
Bytick 2
010 01 ilina
tel.: +421 41 505 5889
fax: +421 41 505 5809
 mailto:[EMAIL PROTECTED]
 http://www.swh.sk/
ICQ:84700861






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php