Forcing vCard downloads on the web
A vCard is like an electronic business card. VCards are often attached to emails, or placed on the contact page of a website (see my contact page, for example). VCards can be easily imported into Outlook, and clicking a vCard link in OSX will automatically add the contact details to your Apple Address Book.
Putting a vCard on your website ought to be very straightforward: just place the file, with its .vcf extension, onto your web server and put a link to it on your contact page. But, like me, you may run into a problem here. When you click on the link in the web page, you may find that the browser opens the vCard file into the browser window, instead of starting a download
There are 2 different ways to solve this problem. The first one is to modify your web server so that it serves up the correct MIME type for the vCard file in the HTTP header. In Apache, for example, you could set this up in the main MIME type configuration file (if you have access to it) or you can set it in a local .htaccess file by adding the following line:
AddType text/x-vcard .vcf
See this article for more details.
The second way to approach the problem is to setup the HTTP headers dynamically. HTTP headers cannot be set on an HTML page of course: an HTML page will have its own headers. To manipulate the headers explicitly you will need to use a server-side scripting language such as PHP or ASP. A decent PHP script for doing this can be found at elouai.com/force-download.php. Note that it is a good idea to hardcode your vCard filename into the script itself to prevent hackers from hijacking the script.

Thanks! This was helpful
Dorie at 7:29 pm on 22 Aug 07
ditto on what dorie said. saved me a good amount of frustration!
Tony at 7:30 pm on 1 Dec 07
Thanks…saved me about 3 hours of time…
Fej at 7:31 pm on 2 Jan 08
any idea how to make this work to download a vCard with mobile Safari on the iPhone?
even with the force-download script the vCard comes up as text on the iPhone.
steve at 9:16 pm on 20 Aug 08
Tha-haa-haaaaank Yoo-hoo-hoooou!!!
I spent 90 minutes trying to figure out what was wrong with my server. After I kludged together a PHP script to solve the problem, I finally found this page. The answer to this relatively common problem is remarkably hard to find. Your explanation was clear and concise. I only wish that I had found it first.
@Steve as far as I know, as of iPhone 2.1, Safari on iPhone still doesn’t support downloading vCards. That’s what sent me on this hunt.
Steve Cotterill at 6:34 pm on 30 Sep 08
Thanks! This fixed my problem.
Rick Winkler at 7:51 pm on 21 Dec 08
Thanks, this was helpful
Irfan at 7:53 pm on 4 Feb 09
This looks like what I need. Thank you.
I’d like to copy and paste the PHP example but I don’t understand what I have to edit in the script to launch my “Vcard.vcf”
Any info would be greatly appreciated.
Thank you.
-Alex
Alex at 2:26 pm on 10 Jun 09
Hi Alex, well if you were using the eLouai script, for example, you would replace the line $filename = $_GET['file']; with $filename = ‘Vcard.vcf’;
(Leaving it to pull out files from the URL is very insecure anyway as this would let people download any random file from your server).
Ben Hayes at 2:43 pm on 10 Jun 09
Hello,
You have described perfectly the dilemma I’ve been dealing with. I’m trying to post the vcard (for download) with out it leading to html text.
Your solutions were beyond me. I do not have server or networking experience. I use Dreamweaver MX on a Mac. Here is an example of the html concerning the vcard:
—————–
<a href=”robwellens.vcf”>vCard</a>
——————-
is there some text command I can place somewhere in this to make the card download.
Thanks for your help.
Rob Wellens at 7:23 pm on 21 Jul 09
Hi Rob,
Unfortunately not, for the reasons I explained in the article: you can’t explicitly set your HTTP headers on a normal HTML page. You could try contacting your hosting provider and ask them to change the MIME type association for .vcf files.
admin at 8:10 pm on 21 Jul 09
This article was very helpful – thank you.
I love your website – the comments ‘balloons’ are fantastic.
Well I’m off to check out some of your other (interesting looking) content.
Thanks again.
Tom
Tom Bannister at 1:03 am on 28 Jan 10
[...] Link: http://www.thesheep.co.uk/2007/06/15/forcing-vcard-downloads-on-the-web [...]
How do I force my V-card file to download? « Dodona gives you answers at 12:56 pm on 22 Feb 10
THANK YOU !
Rosie at 5:53 pm on 30 Apr 10
so, in fact it’s all about a server-side issue. it’s good to have someone else to blame other than myself
now all I need to do is upload my folder and see if it works then.
thanks for the info, mate.
cheers.
Aydin Yavs at 9:04 am on 14 May 10