RE: [PHP] left click downloads

2002-11-13 Thread Javier Montserat
here is a simple function I have created to do single click downloads in php 
-

function sendFile($filepath) {
  $filename = basename($filepath);
  $mimeType = mime_content_type($filepath)
  header("Content-type: $mimeType");
  header("Content-Disposition: attachment; filename=$filename");
  readfile($filepath);
}

In Unix can anyone post a method of obtaining mimeType using the file 
command which could be compatible with this function?

I guess this is possible... my understanding is that mime_content_type() is 
based on unix file commands method of pattern matching 'magic bytes' of 
known file formats.

hope this is useful to some of you...

javier


From: "David Russell" <[EMAIL PROTECTED]>
To: "'Javier Montserat'" <[EMAIL PROTECTED]>
Subject: RE: [PHP] left click downloads
Date: Tue, 12 Nov 2002 13:46:58 +0200

Hi Javier,

Nope, this is not a php thing at all. You could probably get it right
with Javascript or something similar.

HTH

David Russell
IT Support Manager
Barloworld Optimus (Pty) Ltd
Tel: +2711 444-7250
Fax: +2711 444-7256
e-mail: [EMAIL PROTECTED]
web: www.BarloworldOptimus.com

-Original Message-
From: Javier Montserat [mailto:codareef@;hotmail.com]
Sent: 12 November 2002 01:24 PM
To: [EMAIL PROTECTED]
Subject: [PHP] left click downloads


I want to make it easier for people to download files from my website by

having the download start when the visitor clicks a link (as opposed to
right click / save target as).

How can I achieve this with PHP?  Do I include the file in a header()
call ?

Thanks,

javier





_
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus


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

<< smime.p7s >>



_
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join.msn.com/?page=features/virus


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



Re: [PHP] left click downloads

2002-11-12 Thread Ernest E Vogelsinger
At 13:15 12.11.2002, Maxim Maletsky said:
[snip]
>Yes. Just make a header appropriate for browser to understand that it
>should fire up the download dialog.
[snip] 

To force virtually any browser into download mode, specify your content
being an application/octet-stream:

header('Content-Type: application/octet-stream');

Of course, if you're serving an MSWord document (phew) you might have
MSWord open directly in the browser:

header('Content-Type: application/msword');



-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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




Re: [PHP] left click downloads

2002-11-12 Thread Maxim Maletsky
Yes. Just make a header appropriate for browser to understand that it
should fire up the download dialog.


--
Maxim Maletsky
[EMAIL PROTECTED]



"Javier Montserat" <[EMAIL PROTECTED]> wrote... :

> I want to make it easier for people to download files from my website by 
> having the download start when the visitor clicks a link (as opposed to 
> right click / save target as).
> 
> How can I achieve this with PHP?  Do I include the file in a header() call ?
> 
> Thanks,
> 
> javier
> 
> 
> 
> 
> 
> _
> MSN 8 with e-mail virus protection service: 2 months FREE* 
> http://join.msn.com/?page=features/virus
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] left click downloads

2002-11-12 Thread Javier Montserat
I want to make it easier for people to download files from my website by 
having the download start when the visitor clicks a link (as opposed to 
right click / save target as).

How can I achieve this with PHP?  Do I include the file in a header() call ?

Thanks,

javier





_
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus


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