Re: [PHP] How can the Surfer download

2002-01-24 Thread Todd Cary

When the surfer presses a button, I want a pre-determined file to be
downloaded by the surfer - the box to come up on the surfer's browser:
Open or save

Todd

--
Todd Cary
Ariste Software
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Jason Wong

On Thursday 24 January 2002 21:33, Todd Cary wrote:
 When the surfer presses a button, I want a pre-determined file to be
 downloaded by the surfer - the box to come up on the surfer's browser:
 Open or save

Many ways to do this, one of which could be:


  form action=download.php
input type=submit name=submit value=Download
  /form


Then in your file download.php, have a single statement using the header() 
function to redirect to the file that is to be downloaded.



-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Bore, n.:
A person who talks when you wish him to listen.
-- Ambrose Bierce, The Devil's Dictionary
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Todd Cary

Jason -


Then in your file download.php, have a single statement using the
header()
function to redirect to the file that is to be downloaded.


What is the syntax for the header() function?

Many thanks...

Todd

--
Dr. Todd Cary
Ariste Software
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Jason Wong

On Friday 25 January 2002 01:00, Todd Cary wrote:
 Jason -

 
 Then in your file download.php, have a single statement using the
 header()
 function to redirect to the file that is to be downloaded.


 What is the syntax for the header() function?

Manual? Lots of good info in there!


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Fats Loves Madelyn.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Todd Cary

Jason -

I had looked it up in the manual, but I am not sure of what to put into
the area /* ... output pdf file ... */

Any help is appreciated

Todd



If you want the user to be prompted to save the data you are sending,
such as a generated PDF file, you can use the Content-Disposition header
to supply a recommended filename and force the browser to display the
save dialog.

? php header(Content-type: application/pdf);
   header(Content-Disposition: attachment; filename=downloaded.pdf);

   /* ... output pdf file ... */



--
Todd Cary
Ariste Software
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread daniel

Todd-

 I had looked it up in the manual, but I am not sure of what to put into
 the area /* ... output pdf file ... */
 
 Any help is appreciated
 
 Todd
 
 
 
 If you want the user to be prompted to save the data you are sending,
 such as a generated PDF file, you can use the Content-Disposition header
 to supply a recommended filename and force the browser to display the
 save dialog.
 
 ? php header(Content-type: application/pdf);
header(Content-Disposition: attachment; filename=downloaded.pdf);
 
/* ... output pdf file ... */
 
 

This is where you put whatever chunk of code you use to create the
file that you wish the user to download. If this is a PDF file on
disk, you can do something as simple as readfile(filename.pdf)..
or if you are generating it yourself.. then, again, you'll probably
use readfile(whatever.pdf), since (though I have never used them)
I am pretty sure the PDF libs don't have an output function, so you
have to write to disk.

Example 1 on this page (http://www.php.net/manual/en/ref.pdf.php)
shows EXACTLY what you are trying to do with one small change, make
the word inline read as attachment so it'll force the user to
download, as opposed to displaying in the browser.


Daniel J. Lashua


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Todd Cary

Daniel -

When I use the following code, I am not asked if I want to Save the file
or Open it.  Instead, the contents of the file are displayed in the
browser.  I am sure that I have missed something simple!!

Todd

?php
  $len = filesize(test.pdf);
  header(Content-type: application/pdf);
  header(Content-Length: $len);
  header(Content-Disposition: attachment; filename=test.pdf);
  readfile(test.pdf);
?


--
Todd Cary
Ariste Software
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread daniel

Todd-

 When I use the following code, I am not asked if I want to Save the file
 or Open it.  Instead, the contents of the file are displayed in the
 browser.  I am sure that I have missed something simple!!
 
 Todd
 
 ?php
   $len = filesize(test.pdf);
   header(Content-type: application/pdf);
   header(Content-Length: $len);
   header(Content-Disposition: attachment; filename=test.pdf);
   readfile(test.pdf);
 ?

The code you are showing should work... therefore it may be
something to do with your browser. Try changing the Content-Type
to something that there is no way you could have ever registered in
your browser:

header(Content-Type: x-this-is-a-test/for-php);

And see if that changes the way it handles it. Of course,
application/pdf is the CORRECT MIME type, so if this NEW MIME type
does solve the problem, you should attempt to fix your browser, and
put the script back the way it was. If it doesn't fix anything, try
using a different browser, or better yet, a different machine.
Additionally, when working with this type of operation, the first
time you hit the page, it will be cached (in it's incorrect form) in
your browser. Therefore, after making these changes, you should dump
the Disk and Memory cache in your browser, and close and restart
your browser just to be safe.


Daniel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Jason Wong

On Friday 25 January 2002 01:35, Todd Cary wrote:
 Jason -

 I had looked it up in the manual, but I am not sure of what to put into
 the area /* ... output pdf file ... */

 Any help is appreciated


 Todd

 

 If you want the user to be prompted to save the data you are sending,
 such as a generated PDF file, you can use the Content-Disposition header
 to supply a recommended filename and force the browser to display the
 save dialog.

 ? php header(Content-type: application/pdf);
header(Content-Disposition: attachment; filename=downloaded.pdf);

/* ... output pdf file ... */

1) What kind of file are you letting people download?
2) Is the file generated on-the-fly or is it already on disk?
3) What webserver are you using?



In general, if the file is on disk then simply using:

  header(Location: http://www.domain.com/downloads/myfile.exe;);

would work. Whether the user is asked to Save or Open... depends on the 
browser setting.

If you're using a webserver such as Apache then certain common file types are 
automatically recognised and the appropriate HTTP headers are sent to the 
browser.


If you want to force a download regardless of whether the file type will be 
recognised by the browser then you would have to send your own headers. 
Something like the following:

  header(HTTP/1.0 200 OK);
  header(Content-Type: application/octet-stream);
  header(Content-Disposition: attachment; filename=some_filename);
  header(Content-Location: $F);
  header(content-length:  . filesize(/path/to/file.ext));
  header(Location:http://www.domain.com/some_filename;);


hth
-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
TRANSACTION CANCELLED - FARECARD RETURNED
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Jason Wong

On Friday 25 January 2002 02:23, Jason Wong wrote:


 In general, if the file is on disk then simply using:

   header(Location: http://www.domain.com/downloads/myfile.exe;);

 would work. Whether the user is asked to Save or Open... depends on the
 browser setting.

 If you're using a webserver such as Apache then certain common file types
 are automatically recognised and the appropriate HTTP headers are sent to
 the browser.


 If you want to force a download regardless of whether the file type will be
 recognised by the browser then you would have to send your own headers.
 Something like the following:

   header(HTTP/1.0 200 OK);
   header(Content-Type: application/octet-stream);
   header(Content-Disposition: attachment; filename=some_filename);
   header(Content-Location: $F);
   header(content-length:  . filesize(/path/to/file.ext));
   header(Location:http://www.domain.com/some_filename;);

**CORRECTION** (I was trying to adapt some old code to use for this example)

   header(HTTP/1.0 200 OK);
   header(Content-Type: application/octet-stream);
   header(Content-Disposition: attachment; filename=some_filename);
   header(Content-Location: some_filename);
   header(content-length:  . filesize(/path/to/file.ext));
   readfile(/path/to/file.ext);


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Clear the laundromat!!  This whirl-o-matic just had a nuclear meltdown!!
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Jason Wong

On Friday 25 January 2002 02:16, daniel wrote:
 Todd-

  When I use the following code, I am not asked if I want to Save the file
  or Open it.  Instead, the contents of the file are displayed in the
  browser.  I am sure that I have missed something simple!!
 
  Todd
 
  ?php
$len = filesize(test.pdf);
header(Content-type: application/pdf);
header(Content-Length: $len);
header(Content-Disposition: attachment; filename=test.pdf);
readfile(test.pdf);
  ?

 The code you are showing should work... therefore it may be
 something to do with your browser. Try changing the Content-Type
 to something that there is no way you could have ever registered in
 your browser:

 header(Content-Type: x-this-is-a-test/for-php);

 And see if that changes the way it handles it. Of course,
 application/pdf is the CORRECT MIME type, so if this NEW MIME type
 does solve the problem, you should attempt to fix your browser, and
 put the script back the way it was. 

I just want to point out that some versions of IE are notoriously buggy 
(what's new ;-)) and would try to display any type of file regardless of what 
you have for the Content-Type. So if you have a buggy version of IE you need 
to upgrade it.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Accident, n.:
A condition in which presence of mind is good, but absence of
body is better.
-- Foolish Dictionary
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Todd Cary

Jason and Daniel -

Maybe this is a cop out, however it is working.  Comments welcomed..

html
 head
  ?
print('meta http-equiv=refresh content=0; URL=docs/' . $filename
. '');
  ?
titleSendfile/title
 /head
...

--
Todd Cary
Ariste Software
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-24 Thread Jason Wong

On Friday 25 January 2002 03:06, Todd Cary wrote:

 Jason and Daniel -

 Maybe this is a cop out, however it is working.  Comments welcomed..

 html
  head
   ?
 print('meta http-equiv=refresh content=0; URL=docs/' . $filename
 . '');
   ?
 titleSendfile/title
  /head
 ...

Hmm, but if the file was a recognised type then this would just display the 
file in your browser. So wouldn't it be easier to use the header(Location: 
...) example that I gave earlier?


In any case I thought your objective was to display a Save/Open ... dialog?



-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
I have a terrible headache,  I was putting on toilet water and the lid fell.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] How can the Surfer download

2002-01-23 Thread Todd Cary

What is the syntax to give the surfer an opportunity to download a file?

Todd

--
Todd Cary
Ariste Software
[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can the Surfer download

2002-01-23 Thread Jason Wong

On Thursday 24 January 2002 13:27, Todd Cary wrote:
 What is the syntax to give the surfer an opportunity to download a file?

Please elaborate.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Kitchen activity is highlighted.  Butter up a friend.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]