I have an e-commerce website and I am trying to have a webpage create a .doc or .rtf document to print labels based on the customers' addresses in a mysql database.
For this reason, I need to create a document based on a labels template.
I have saved the labels template as whslabels.rtf on the website, and on every label I have written "Address1", "Address2", "Address3", ... then I have the mentioned webpage do a str_replace replacing the "Address..." words with the customer's address, and then save this to a new file named "newlabels6.rtf".
$template_file = "whslabels.rtf";
$handle = fopen($template_file , "r");
$contents = fread($handle, filesize($template_file));
$original= array("Address1", "Address2");
$new = array("pizza", "beer");
$newphrase = str_replace($original, $new, $contents);
$handle2 = fopen("newlabel6.rtf" , "w");
fwrite ( $handle2 ,$newcontents);
fclose ($handle);
fclose($handle2);
but when I go to open the new .rtf file it doesn't seem to able to open it. The exact error I get is "The document file or path is not valid...."
What am I doing wrong?