Closed netidan closed 8 years ago
Hi @netidan,
Can you give a little more information about which framework you are using?
Which function do you use? ->download()
?
what do u mean freamwok? bootstrap etc? i want to add that the vcards image also not working in lg phones i checked (g3,g4) yes im using ->download() this is the code im using to create the vcard:
<?php
/**
require_once DIR . '/vendor/autoload.php'; require_once DIR . '/src/VCard.php';
use JeroenDesloovere\VCard\VCard;
// define vcard $vcard = new VCard();
// define variables $fullname = explode(' ',$_POST['name']); $firstname = $fullname[0]; $lastname = $fullname[1].' '.$fullname[2]; $additional = ''; $prefix = ''; $suffix = '';
// add personal data $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix);
// add work data $vcard->addCompany($_POST['company']); $vcard->addJobtitle($_POST['job']); $vcard->addEmail($_POST['email']); $vcard->addPhoneNumber($_POST['phone'], 'WORK'); $vcard->addPhoneNumber($_POST['cell'], 'CELL'); $vcard->addPhoneNumber($_POST['fax'], 'WORK;FAX'); $address = explode(', ', $_POST['address']); $vcard->addAddress(null, null, $address[0], $address[1], null, null, $address[2]); $vcard->addURL($_POST['website'],'WORK');
$vcard->addPhoto($_POST['image']);
return $vcard->download();
Hi @netidan, by framework I mean something like Symfony2, Laravel, CakePHP, ZendFramework, ... Each has its own way of handling "http headers", which are required for outputting the ".vcard".
I'll have to check with my hosting. I'll update soon
@netidan, I guess that $fullname can potentially trigger an error why its not exporting! Wait, I'm rewriting your code.
$nameVars = explode(' ', $_POST['name']);
$firstname = (isset($nameVars[0])) ? $nameVars[0] : '';
$lastname = (isset($nameVars[1])) ? $nameVars[1] : '';
$lastname .= (isset($nameVars[2])) ? ' ' . $nameVars[2] : '';
You should also check if every $_POST exists, because otherwise this can throw errors in your code, resulting in not exporting the .vcard.
yes they all work, it also works in other devices i checked (apple,samsung,oneplus,nexus) and also works on pc. the problem only occurs to me on lg devices (i checked g3 and g4)
about the framework, sorry i misunderstood, im not using any php framework. its a wordpress site, using a template based on pure php without any framework. the only framework in use is bootstrap3
hi jeroen, i changed my code as you instructed, but the problem remains. i try to rewrite the code, saving only name without variables at all, still always get the error, and only in lg phones in the native browser. the problem does not occur on chrome. did u checked the problem on lg native browser? thanks
http://bestcard.co.il/gil-shemgar/ the download contact button is the blue button with the user and + icon on it
@netidan Probably something to do with the headers
Hi @netidan, I'm coming back to you with your image problem. I've downloaded the vcard from the URL you provided and copy/pasted the image base encoding "data URI" from the .vcard to an image converter website. And the image is showing up fine.
I'm sorry, I don't have an LG phone, so I can't test your problem ;-( Did you find a solution yet?
hi, i didnt find a solution, the problem occurs on any android phone while using native android browser, i have given up on this matter. but thanks for the support :)
I think that the problem lies with the PHP headers that are being send because you said that "nothing happens" - Found a similar problem
Can you test these headers?
// Defining parameters
$fileName = 'contact.vcf';
$length = filesize($fileName);
$content = file_get_content($fileName);
header('Content-Description: File Transfer');
header('Content-Type: text/vcard');
header('Content-Disposition: attachment; filename=' . $fileName);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . $length); //Set content length here
ob_clean();
flush();
echo $content; //echo the content
exit;
hi jeroen, i dont understand where to add this code, could you please help? this is my code for generating vcard:
require_once DIR . '/vendor/autoload.php'; require_once DIR . '/src/VCard.php';
use JeroenDesloovere\VCard\VCard;
// define vcard $vcard = new VCard();
// define variables $nameVars = explode(' ', $_POST['name']); $firstname = (isset($nameVars[0])) ? $nameVars[0] : ''; $lastname = (isset($nameVars[1])) ? $nameVars[1] : ''; $lastname .= (isset($nameVars[2])) ? ' ' . $nameVars[2] : '';
$additional = ''; $prefix = ''; $suffix = '';
$image = isset($_POST['image'])?$_POST['image']:'';
// add personal data $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix);
// add work data $vcard->addCompany($_POST['company']); $vcard->addJobtitle($_POST['job']); $vcard->addEmail($_POST['email']); $vcard->addPhoneNumber($_POST['cell'], 'CELL'); $vcard->addPhoneNumber($_POST['phone'], 'WORK'); $vcard->addPhoneNumber($_POST['fax'], 'WORK;FAX'); $address = explode(', ', $_POST['address']); $vcard->addAddress(null, null, $address[0], $address[1], null, null, $address[2]); $vcard->addURL($_POST['website'],'WORK');
$vcard->addPhoto($image);
return $vcard->download();
Hi @netidan,
Are you using composer require jeroendesloovere/vcard
to load in the VCard?
Hi Jeroen, I need your help, I have been using your package in laravel 5.8, I am not able to download vcf in mobile phone that gets failed but it is able to download in desktop, using crome browser, check this at least 5 mobile phone same issue has been occurred.. First I am using this code static not changing data dyanamic
$vcard = new VCard();
// define variables
$lastname = 'Desloovere';
$firstname = 'Jeroen';
$additional = '';
$prefix = '';
$suffix = '';
// add personal data
$vcard->addName($lastname, $firstname, $additional, $prefix, $suffix);
// add work data
$vcard->addCompany('Siesqo');
$vcard->addJobtitle('Web Developer');
$vcard->addRole('Data Protection Officer');
$vcard->addEmail('info@jeroendesloovere.be');
$vcard->addPhoneNumber(1234121212, 'PREF;WORK');
$vcard->addPhoneNumber(123456789, 'WORK');
$vcard->addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium');
$vcard->addLabel('street, worktown, workpostcode Belgium');
$vcard->addURL('http://www.jeroendesloovere.be');
//$vcard->addPhoto(__DIR__ . '/landscape.jpeg');
// return vcard as a string
//return $vcard->getOutput();
// return vcard as a download
return $vcard->download();
Kindly Help me..
I am also facing the same issue with https://help.grandelectronics.in/contacts/vcard
this is working well in iphone and windows PC, but Android ask for download.
$vcard = new \JeroenDesloovere\VCard\VCard(); // define variables $lastname = 'Electronics and Home Appliances'; $firstname = 'Grand'; $additional = ''; $prefix = ''; $suffix = ''; $vcard->addName($lastname, $firstname, $additional, $prefix, $suffix); $vcard->addCompany('Thamarassery, Poonoor'); $vcard->addEmail('grandtrsy@gmail.com'); $vcard->addPhoneNumber('91 97459 06070', 'PREF;MAIN'); //Billing main $vcard->addPhoneNumber('91 85939 06070', 'CELL'); //poonoor $vcard->addPhoneNumber('91 97453 06070', 'WORK'); ///Service $vcard->addAddress(null, null, 'Thamarassery & Poonoor', null, '', ''); $vcard->addLabel('Thamarassery & Ponoor, Kerala, India.'); $vcard->addURL('https://egrand.in'); $vcard->addURL('https://wa.me/919745306070', 'WhatsApp'); $vcard->addNote('Your one-stop destination for all electronics, home appliances, and smartphones from major brands. EMI options available.'); $vcard->addPhoto('https://help.grandelectronics.in/img/logo.png'); return $vcard->download();
hi man, thanks again for this plugin, im having problems saving the vcf file, when i click on the download button nothing happens, i see the url is changing to the php file i made, but the download of the vcf file is not starting. thanks