Hi all,
I'm trying to copy a file from one location and place it in a newly created folder via a basic form. The user enter their ID and then clicks continue.
The process got as follows:
//create user folder and permissions
<?php
mkdir("logs/AN".$_POST[pNum], 0777);
?>
// open txt file for edidting and inserts user ID
<?php
$filename = 'test.ini';
$somecontent = 'PilotNumber=' .$_POST[pNum];
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
What I'd like to be able to do is to copy the test.ini file into the newly created user folder, then open that file and make changes there. Then the user will have access to their folder where they can download this file.
I have tried using the variable but I get an error :
"Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/myDomain/public_html/mydir/fsacars/temp/copy.php on line 3"
The code I am trying to use is
<?php
$from = '../test.ini';
$to = '../logs/'.$_POST[pNum]'/AN.ini';
copy($from, $to);
?>
So the end result should be a folder like /logs/123/test.ini
Hope I made sense and that someone can see where I've gone wrong.
Cheers
Steph.