I have this feature on a site for people to upload and download files.
I needed the files to be downloaded via save as/ open dialog box, whether it was a jpeg, or pdf, or txt file.
To accomplish this I used header() in php. and it works fine in pc's.
Unfortunately, for some reason when mac's try to download it the file downloads, but also adds the contennt of download.php (actual code) in the file, which corurmpts the file.
Basically, i have the download system like so,
on a download_page.php I have buttons which are
onClick="javascript to foward("download.php?file=12");
on download.php I have:
<?php
@$getid=$_GET['file'];
if ($getid!=="") getdownload($getid);
///// comes back with file information including location on the server
$name2=basename($file_location);
$name=strrev($name2);
$name=substr($name, 0, 3);
$name=strrev($name);
//// just some file name manupulation to find extensions. I've since learned much easier way of doing this////
$name3=strrev($name2);
$name3=substr($name3, 0, 9);
$name3=strrev($name3);
$name3=str_replace($name3, "", $name2);
$name3=$name3.".".$name;
//// file names have random 4 digit number on them to prevent overides.
this is where i remove them. I basically just remove the last 9 charachters. 3 extenstion + 1 dot + 4 numbers + 1 underscore = 9 charachters, then it adds the extesion from $name ////
$head1="Content-type: application/".$name;
header($head1);
$head2="Content-Disposition: attachment; filename=".$name3;
header($head2);
readfile($file_location);
?>
every file is being downloaded on macs at about 80k above original file size. It puzzels me that this only happens in macs.
What do you think could be a problem or how else can I solve this issue?