I'm currently trying to have my website automatically move a file from the root directory where it is created into another folder to help with organization. I'm using the PHP rename() function and I can get it to work with literal strings but when I try using the variable name I get the error
PHP Warning: rename() expects parameter 1 to be a valid path, resource given in...
My code works when I use,
$txt = "Additional Comments: ".$_POST['additionalComments']."
";
fwrite($myfile, $txt);
fclose($myfile);
rename('Leadership_Review2.txt', 'Leadership_Review/Leadership_Review2.txt');
However, when I use
$txt = "Additional Comments: ".$_POST['additionalComments']."
";
fwrite($myfile, $txt);
fclose($myfile);
$mydir = "Leadership_Review/";
rename($myfile, $mydir.$myfile);
I get the error mentioned above. It would be a lot more useful if I could use the variable name instead of having the literal string. Any help understanding rename or where I am going wrong would be greatly appreciated. Thanks!