copy(): The first argument to copy() function cannot be a directory

Oct 21, 2014 at 3:36 PM
Hi I am having a problem with saving a document from a template.

I have a total of 147 templates, but at any point in time only need 20 of them, but once placed they need to be sequentially named, I have already dealt with this from the following code:
//Add Template Documentation
//step 1 identify which documentation set is required
$sql = "SELECT * FROM templates_documents WHERE scope = '".$values["msscope"]."'";
$rs = CustomQuery($sql); 
$results = $rs;
while ($row = $results->fetch_assoc())
//Step 2 correctly name doc reference
if ($row["scope"] == '9001') $docref = $row["9001ref"]; 
elseif ($row["scope"] == '14001') $docref = $row["14001ref"]; 
elseif ($row["scope"] == '18001') $docref = $row["18001ref"]; 
elseif ($row["scope"] == '9001,14001') $docref = $row["914001ref"]; 
elseif ($row["scope"] == '9001,18001') $docref = $row["918001ref"]; 
elseif ($row["scope"] == '14001,18001') $docref = $row["1418001ref"]; 
elseif ($row["scope"] == '9001,14001,18001') $docref = $row["91418001ref"];

//Step 3 Decode Attachment Field
$fileArray = json_decode($row["attachment"],true);

//values from Attachment Array
$name1 = $fileArray["0"]["name"]; 
$usrName1 = $fileArray["0"]["usrName"];
$size1 = $fileArray["0"]["size"];
$type1 = $fileArray["0"]["type"];
$searchStr1 = $fileArray["0"]["searchStr"];

$name2 = $folder.'/'.$docref.'.docx';
$usrName2 = $docref.".docx";
$searchStr2 = $usrName2.",!:sStrEnd";
$attachment2 = '[{"name":"'.$folder.'\/'.$usrName2.'","usrName":"'.$usrName2.'","size":'.$size2.',"type":"'.$type2.'","searchStr":"'.$searchStr2.'"}]';
The above all works fine, but I get problems after introducing the following PHPWord code:
require_once 'plugins/PHPWord/Template.php';
require_once 'plugins/PHPWord.php';
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('/home/sites/'.$name1);
The error coming up is in this screenshot

I have tried using relative and absolute paths, and cant figure out the problem

from a var_dump I can see that the $name 1 and $name2 functions are working, ie in example I am trying $name1 returns Templates/test_rsnglzbn.docx and $name2 returns ClientFiles/152/PM-01.docx which is correct. However if you look at error line 2 on the screenshot, it looks like the path is not correctly set.

Please help?
Oct 21, 2014 at 7:58 PM