I’m trying to move all images files from folder into another folder but i’m having this warning and i can’t go further, did some search here but not getting the desired solution
having those errors
Warning: copy(): The first argument to copy() function cannot be a directory in /home/XXX/public_html/miga/db/teste.php on line 16
Warning: copy(): The first argument to copy() function cannot be a directory in /home/XXX/public_html/miga/db/teste.php on line 16
Warning: copy(): The first argument to copy() function cannot be a directory in /home/XXX/public_html/miga/db/teste.php on line 16
error_reporting(E_ALL);
ini_set('display_errors', 1);
$files = scandir("../uploads");
$source = $_SERVER['DOCUMENT_ROOT'] . '/miga/uploads/';
$haveImages = glob($source."*.{jpg,jpeg,png,gif}", GLOB_BRACE);
$keepFiles = array('miga.png');
$destination = $_SERVER['DOCUMENT_ROOT'] . '/miga/media/';
if(!empty($haveImages)){
echo $source;
foreach ($files as $file) {
if (in_array($file, array(".",".."))
) continue;
// If we copied this successfully, mark it for deletion
if (copy($source.$file, $destination.$file)) {
$delete[] = $source.$file;
$gravacao[] = $source.$destination;
}
}
}
else{
echo "here 0";
}