i got it actually.
using this:
$filename ='C:\some\path\excelreport.xls';
$path = 'C:\some\path\excelreport.xls';
if(file_exists($path)):
$fh = fopen($filename, "a") or die("can't open file");
$contents = "name \t companyName \t address \t num \t email \t url \t \n";
fwrite($fh, $contents);
fclose($fh);
echo 'file exist';
else:
echo 'does not exist';
endif;
but i'm having trouble on this one:
$filename ="excelreport.xls";
$path = 'C:\some\path\excelreport.xls';
if(file_exists($path)) {
$filepath = 'C:\some\path\excelreport.xls';
$fh = fopen($filepath, "a") or die("can't open file");
$write = "$name \t $companyName \t $address \t $num \t $email \t $url \t \n";
fwrite($fh, $write);
fclose($fh);
exit;
} else {
$contents = "NAME \t COMPANY NAME \t ADDRESS \t PHONE NUMBER \t EMAIL \t URL \t \n";
$contents .= "$name \t $companyName \t $address \t $num \t $email \t $url \t \n";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=".$filename);
header("Content-Transfer-Encoding: binary ");
echo $contents;
}
it executes the else statement even though the file exist.
any ideas?