VCard.vcf download browser support - godaddy

I have a link to download vCard (.vcf) on the site. It works locally, but not on the Internet. It simply opens the file in the browser without downloading. I would rather not loop it.

Read and find that I need to put this:

AddType text/x-vcard .vcf

in the .htaccess file. but it still does not work. Am I missing something?

Site hosted by godaddy. One old thread that I read somewhere had a guy who earned it, but no more information than the .htaccess bit.

+3
source share
3 answers

It turns out that I'm doing it right, it just took some time for it to start working. Then, when it wasn’t working yet, Firefox had to clear the offline memory and started working too.

+3
source

, AddType, , . , , .

, PHP script, .

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");
 ?>

VCF .

+5

Based on the MIME type (in your text message / x -vcard), the browser decides that the weather will open the file inside the browser or start downloading.

One simple way is to tell the server to suggest files ending in .vcf using the ohter MIME type. Here you must choose the type in which you can be sure that the browser will always load it:

Try: AddType application/octet-stream vcf

+2
source

Source: https://habr.com/ru/post/1794693/


All Articles