PHP JeroenDesloovere's VCard download/import issue - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, May 4, 2023

PHP JeroenDesloovere's VCard download/import issue

I've installed the library via cmd and used the code like below. However file is not being downloaded at safari with "Safari can't download this file" error (translation may be wrong). In Android systems a 3 KB .vcf file being downloaded but it's not importing any data.

require_once('../vendor/autoload.php');

use JeroenDesloovere\VCard\VCard;

if(isset($_GET['download'])){
        
        // Output the vCard data to the browser
        header('Content-Type: text/vcard');
        header('Content-Disposition: attachment; filename="contact.vcf"'); 
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
        header('Expires: 0');
    
         // Create a new vCard instance
        $vcard = new VCard();
    
        // Set the vCard properties
        $vcard->addName('Doe', 'John', '', 'Mr.');
        $vcard->addFormattedName('John Doe');
        $vcard->addCompany('Acme Inc.');
        $vcard->addJobtitle('CEO');
        $vcard->addPhoneNumber('+1-555-555-1212', 'WORK');
        $vcard->addPhoneNumber('+1-555-555-1234', 'HOME');
        $vcard->addAddress('123 Main St', 'Suite 100', 'Anytown', '12345', 'USA', 'WORK');
        $vcard->addEmail('john.doe@acme.com');
    
        // Output the vCard data to the browser
        echo $vcard->getOutput();
        exit; 
        
}


?>

<div class="shortcol">
    <a href="?download" class="download-link">
         <span class="fa-stack" style="font-size: 1.6em;">
            <i class="fas fa-circle fa-stack-2x" style="color: #32afee";></i>
            <i class="fa-solid fa-arrow-down fa-stack-1x fa-inverse style"></i>
            </span>
    </a>
</div>


source https://stackoverflow.com/questions/76166891/php-jeroendeslooveres-vcard-download-import-issue

No comments:

Post a Comment