'....Failed to open stream: No such file or directory in
I am working on a signup page.
I want to copy a file to another directory via the copy function:
It makes a folder with a variable as the name like so:
mkdir($skool, 0700);
Then I make variables for the source and the destination and then copy them like so:
$source = 'indexa.php';
$destination = 'localhost/school/choose/$skool/indexa.php';
if( !copy($source, $destination) ) {
echo "File can't be copied! \n";
}
else {
echo "File has been copied! \n";
}
I am using that skool variable, note.
I know this file exists but it flags up the following error:
copy(localhost/school/choose/indexa.php): Failed to open stream: No such file or directory in the file on line 148
I am not sure where I am going wrong: please help!
Solution 1:[1]
This code will not work correctly because variable $skool inside single quotes
$destination = 'localhost/school/choose/$skool/indexa.php';
Try to take out a variable like this:
$destination = 'localhost/school/choose/' . $skool . '/indexa.php';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
