PDA

View Full Version : PHP Force Download on a MAC?


AndySmith
08-12-2004, 03:01 PM
Hi,

I'm using this script (thanks to freddycodes) to force download mp3 files. It works fine on PC's but doesn't work on MACs.

<?php
header("HTTP/1.0 204 No Content");
$basedir = "http://www.website.com/audio/";
header("Content-Type: octet/stream");
header("Content-Disposition: attachment; filename=\"".$_GET['file']."\"");
$fp = fopen($basedir.$_GET['file'], "r");
$data = fread($fp, filesize($basedir.$_GET['file']));
fclose($fp);
print $data;
}
?>

Does anyone have any ideas?

Thanks,

Andy

Dark_Element
08-13-2004, 12:40 PM
I'll assume your trying to say your using PHP to set the header which forces the user to download mp3 files (cos PHP can't influence the client directly its the PHP group's policy).

Well my knowleges of Macs and their browsers ain't so good but i think its proberbly it has a different header reader than normal IE? anyways why are you forcing the client to download stuff? dont you think that its a bit... err annoying?

note: i don't think you should go and bust your mind on such a thing... its not like you will lose so much trafic if mac users won't be able to download the file...is it?

AndySmith
08-13-2004, 04:46 PM
The reason I'm trying to 'force' a download, is because I have mp3's available on my site for download, but I don't want to ZIP them. So, by using this method, the user can click on the download link, and then can select where they want to save the mp3 on their hard disk. If anyone knows of any better way, that would be great.

It works in Safari on a Mac but not in IE. If anyone has an ideas it would be helpful.

note: i don't think you should go and bust your mind on such a thing... its not like you will lose so much trafic if mac users won't be able to download the file...is it?

I like things to work properly - on all platforms, not just PC's.

Andy