0

I have written a little PHP file, that creates a new folder and is supposed to copy a file from a constant location to this newly created folder. As the function is supposed to always work, no matter from which location on the server it is executed, I would like to use a absolute path to the file to copy.

Now everything is working as I want to, except, when I use an absolute path to the file. The file exists, and the folder has gotten the same permissions. I am on a Windows machine for testing, so permissions should propably not be the issue.

copy('/roessle/ressources/index.php', $newDirInd);

the folder roessle is a folder in the root folder of my Apache webserver, so one layer below the directory I would land in when just type in localhost.

now what is wrong with that path? the file exists, and I have checked for typos like 100 times, but it just won't work.

1 Answers1

0

That's an not an absolute path in your filesystem. Try this:

copy($_SERVER['DOCUMENT_ROOT'].'/roessle/ressources/index.php', $newDirInd);
markmoxx
  • 1,492
  • 1
  • 11
  • 21