WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm developing my own plugin. in that i used a simple php file to generate contact vcards in the plugin folder. for this i used fopen & fwrite. but the file is not creating in the plugin folder. this is my code:

function Vcard(){
$path =EMAIL_PLUGIN_URL.'/MyFile.txt';
$Handle = (file_exists($path))? fopen($path, "a+") : fopen($path, "w+");
$sql="select the rows from my db";
$rs =/* db array result*/
 while(until the last result) {
 $Data="BEGIN:VCARD"."\n"."VERSION:2.1"."\n";  $Data.="N:".$row['eemail_name_sub'].';'."\n"."FN:".$row['eemail_name_sub']."\n";
 fwrite($Handle, $Data);
$p="data written";
 return $p;

What may be the reason for this? also how can i download this vcard at the same moment after it is created and written?

share|improve this question
Does fopen() call work at all (not return false)? Why do you need to save these files? From personal experience vcards are easier to just generate and serve on the fly. – Rarst Jun 5 '14 at 15:15
there is a list of patient numbers and names and i need to integrate those numbers to phone contacts. for that one method i thought is to generate .vcf files so that it would be easier for syncing with phone contacts. the php file works in separately run but when i paste the file in plugin folder fopen is not creating file – Ammu Jun 6 '14 at 3:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.