Best solution is to offer 'right click save as' instead of forcing download.
You could use .htaccess in your download directory written
Code:
<Files *.vcf >
ForceType application/octet-stream
Header set Content-Disposition attachment
</Files>
This may work for Mozilla clients but IE may cause problems.
Could you not zip the .vcf files as zips always force a download.
Also theres a scripting solution by linking your vcf file to 'download.php' script. This is a possible solution for a single file only which is hard coded into the script. There are security issues if done dynamically although sure theres a solution if you Google it. This script hasn't been tested - but something along these lines.
Code:
// download.php
$path = "foo.vcf"; // hard coded vcf file here
try {
if (is_file ($path)){
if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
$f .= fread($file, 1024*8);
}
fclose($file);
}
//Use the header function
$outputname = "anyName";
header ("Content-type: text/x-vcard ");
//This will force a download.
header("Content-disposition: attachment; filename=".$outputname.".vcf");
print $f;
} else {
throw new exception ("Sorry, file path is not valid.");
}
} catch (exception $e){
echo $e->getmessage();
}
Last edited by maxxximus : 11-20-2007 at 05:32 AM.
|