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");

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...


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.


David Russell
IT Support Manager
Barloworld Optimus (Pty) Ltd
Tel: +2711 444-7250
Fax: +2711 444-7256

-----Original Message-----
From: Javier Montserat [mailto:codareef@;]
Sent: 12 November 2002 01:24 PM
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 ?



MSN 8 with e-mail virus protection service: 2 months FREE*

PHP General Mailing List (
To unsubscribe, visit:

<< smime.p7s >>

MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to