Hi All! Need help from a PHP expert! I want to go through my picture files and pull out only what is being used. I want to list the files on a txt list or in a mysql table and copy the files on the list to a new folder.
I got help on Experts Exchange but we can not make the code work. I have the skutlist.txt and the copyfromherefolder and copiedpictsfolder installed in my /httpdocs folder.The codde below does not seem to be reading the simulated list in copyfiles.php. It gives error "NOT READABLE". Could this be a permission problem on the server?

My Code:<?php
error_reporting(E_ALL);

// SET THE INPUT AND OUTPUT DIRECTORIES
$in = 'copyfromherefolder';
$ot = 'copiedpictsfolder';
// SIMULATE READING THE LIST OF FILE NAMES WITH file_get_contents('skulist.txt');
$skulist = <<<SKULIST
11003.jpg
11003QC.jpg
11007.jpg
11007A.jpg
11011G2152132L.jpg
11017.jpg
11018.jpg
11019.jpg
11020AT-15.jpg
11023AT-15.jpg
11028.jpg
SKULIST;
// MAKE AN ARRAY FROM THE LIST
$arr = explode(PHP_EOL, $skulist);
// ACTIVATE THIS TO SEE THE ARRAY
// var_dump($arr);
// ITERATE OVER THE ARRAY
foreach ($arr as $f)
{
// REMOVE UNWANTED EOL CHARACTERS
$f = trim($f);
// REMOVE CACHED FILE INFORMATION
clearstatcache();
// CREATE FILE PATHS
$i = $in . DIRECTORY_SEPARATOR . $f;
$o = $ot . DIRECTORY_SEPARATOR . $f;
// CAN WE READ THE FILE?
if (is_file($i))
{
if ($x = copy($i, $o))
{
echo PHP_EOL . "<br/>COPIED $i TO $o";
}
else
{
echo PHP_EOL . "<br/>DID NOT COPY $i TO $o";
}
// IF COPY SUCCESSFUL - OPTIONALLY REMOVE THE OLD VERSION
// if ($x) unlink($i);
}
else
{
echo PHP_EOL . "<br/>NOT READABLE: $i";
}
}