As it stands I have my files being displayed in an array, I am trying to create a function to make a copy of the file in the users directory as it stands my function is as follows:
function copyFile($dir, $fileToCopy){
if (is_dir($dir)) {
if ($dirHandle = opendir($dir)) {
$files = array_diff(scandir($dir), array('.', '..', '.htaccess'));
if($files){
foreach($files as $file){
if($file === $fileToCopy) {
copy($dir."\\".$fileToCopy, $dir."\\");
$output = 'Successfully copied file: '.$fileToCopy;
}
}
}
}
}
return $output;
}
if(isset($_POST)){
echo copyFile($_SESSION['UserFolder'], $_POST['fileToCopy']);
}
The output is given when i click the button to copy the file but nothing happens with regards to the file being copied the buttons code is like so:
'<form action="MyFiles.php" method="POST"><input type="hidden" value="'.$file.'" name="fileToCopy"/><input type="submit" value="Copy" name="copyButton"/></form>'
hope I explained well enough would love some feedback