I have a download vCard (.vcf) link on a site. It works locally but not online. Just opens file in browser without downloading. I would rather not have to zip it.
Read around and found I need to put this:
AddType text/x-vcard .vcf
in a .htaccess file. but it's still not working. Am I missing something?
The site is hosted with godaddy. One old thread I read somewhere had a guy who made it work but no more info other than the .htaccess bit.
As a first step, ask Godaddy whether they support AddType
directives and if yes, how. That solution would definitely be preferable.
Alternatively, you may be able to work around it using a primitive PHP script that sends the correct headers.
contact.php (untested):
<?php
# Send correct headers
header("Content-type: text/x-vcard");
// Alternatively: application/octet-stream
// Depending on the desired browser behaviour
// Be sure to test thoroughly cross-browser
header("Content-Disposition: attachment; filename=\"contact.vcf\";");
# Output file contents
echo file_get_contents("contact.vcf");
?>
this would serve the VCF file with the correct header.