Re: [PHP] Foring a file download *and* page reload

2003-09-02 Thread Marek Kilimajer
You can use either a meta tag or real header, the later is prefered.

?php

header('Refresh: 0; url=download.zip');

?
html
!-- your html page here --
/html
The browser loads the page and immediatly goes to another page 
(download.zip). This page will prompt the Save As dialog.

Jean-Christian IMbeault wrote:
Marek Kilimajer wrote:

But because explorer does not support multipart/mixed and it is still 
the major browser (thought not for long ;), do it this way. Output 
header('Refresh: 0; url=download.zip'); first and then load the html 
page with new data blocks.


Sorry if the solution is obvious but I can't understand what you mean by
using a refresh header. Where and when should I use the header? Can you
give a short example?
Thanks,

Jean-Christian Imbeault

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


Re: [PHP] Foring a file download *and* page reload

2003-09-01 Thread Jean-Christian IMbeault
Marek Kilimajer wrote:
 
 But because explorer does not support multipart/mixed and it is still 
 the major browser (thought not for long ;), do it this way. Output 
 header('Refresh: 0; url=download.zip'); first and then load the html 
 page with new data blocks.

Sorry if the solution is obvious but I can't understand what you mean by
using a refresh header. Where and when should I use the header? Can you
give a short example?

Thanks,

Jean-Christian Imbeault

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



[PHP] Foring a file download *and* page reload

2003-08-29 Thread Jean-Christian IMbeault
I've asked about this before but could not get a working solution.

I have a database. Users put data in the DB :) I have a page with a list 
of accessible data block. Each block has a button next to it.

When a user click a button what I would like is:

- I extract the data block from the DB
- I send the data to the browser as a file download so the user can save 
the data block to disk. (i.e. a save-file-as dialog comes up)
- I mark the data block as inaccessible
- I reload the page and present a new list. The data block the user as 
just selected is no longer in the list.

I have figure out how to force a file download using:

header(Content-disposition: attachment; filename=aFile);
header(Content-type: application);
The problem I have is that I need a way of send the user back to list 
page so I can regenerate a new listing. I can't use header(Location) 
because I've already started an output stream (the download).

Some suggested using this header:

header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\);

But I could quite get it to work. The example code I have been trying to 
get to work make Netscape open a save-as dialog three times and on IE 6 
just prints everything in the browser window. This is the code:

(suggested by Marek Kilimajer)
?
header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\);
print ---Boundary-12399\r\n;
print Content-Type: text/html\r\n;
print \r\n;
//HTML code goes here

print \n;
print ---Boundary-12399\r\n;
print Content-Type: application/octet-stream\r\n;
print Content-Disposition: attachment; filename=foo.tar.gz\r\n\r\n;
readfile(./foo.tar.gz);
print ---Boundary-12399--\r\n;
print \r\n;
?
I'm sure someone has done this before :) What is the correct way to 
achieve this effect? Is multipart content-type the way to go?

Thanks,

Jean-Christian Imbeault

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


Re: [PHP] Foring a file download *and* page reload

2003-08-29 Thread Curt Zirzow
* Thus wrote Jean-Christian IMbeault ([EMAIL PROTECTED]):
 I've asked about this before but could not get a working solution.
 
 I have a database. Users put data in the DB :) I have a page with a list 
 of accessible data block. Each block has a button next to it.
 
 When a user click a button what I would like is:
 
 - I extract the data block from the DB
 - I send the data to the browser as a file download so the user can save 
 the data block to disk. (i.e. a save-file-as dialog comes up)
 - I mark the data block as inaccessible
 - I reload the page and present a new list. The data block the user as 
 just selected is no longer in the list.

What you are trying to do is virtually impossible. Due to HTTP
protocal's statelessness, you cant relyably reload the page after
the person has clicked on it. 

Then you have issues like what if the person is using a download
manager (external to the browser), or his connection drops, etc..

 ...
 
 (suggested by Marek Kilimajer)
 ?
 header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\);

This will only work if the browser supports multipart/mixed. And I
don't think any browser supports this.

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] Foring a file download *and* page reload

2003-08-29 Thread Marek Kilimajer
Curt Zirzow wrote:

...

(suggested by Marek Kilimajer)
?
header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\);


This will only work if the browser supports multipart/mixed. And I
don't think any browser supports this.
I bet any browser except explorer ;)

But because explorer does not support multipart/mixed and it is still 
the major browser (thought not for long ;), do it this way. Output 
header('Refresh: 0; url=download.zip'); first and then load the html 
page with new data blocks.

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