Have never gotten to work successfully...
Something tells me I am not using the foreach correctly?
I've tested with just one pic that I know exists in the temp table, but it never gets copied.
Below is the code:
<?php
set_time_limit(0);
//*************************************************************************************
//Variables used through out the script
//*************************************************************************************
$server = "localhost";
$database = "ndorfnz_com"; // Database Name
$dbtable = "photoids2"; // Table Name
//*************************************************************************************
//Make server and database connections
//*************************************************************************************
$con = mysql_connect("$server",$userid,$pass)
or die ("Connection Error to Server");
$db = mysql_select_db("$database",$con)
or die("Connection Error to Database");
//local path containing ALL THE PHOTOS!!!
$s = "c:/allraces";
if (!$s)
{
echo "Error: Must specify a directory to view as readDir.php?s=somedir"; exit;
}
else
{
}
//DIM THE LOCAL FILES PATH ARRAY
$localPics = Array();
//OPEN UP THE DIRECTORY
$handle=opendir($s);
//LOAD THE LOCAL FILE PATH ARRAY UNTIL ALL FILES ARE READ
while (($file = readdir($handle))!==false)
{
if ($file)
{
//LOWERCASE THE FILES, SOME .JPG AND SOME .jpg
$file2 = strtolower($file);
//LOAD ARRAY
$localPics[] = "$file2"."";
}
}
$query = "SELECT photoid from photoids2";
$result = mysql_query($query);
//DIM THE ARRAY FOR MYSQL TABLE, THIS TABLES STORES ALL THE PICS THAT ARE LIVE ON THE WEB
$livePics = Array();
//FILL THE ARRAY WITH RESULTS FROM THE MYSQL TABLE
while ($row = mysql_fetch_array($result))
{
$livePics[] = $row[photoid];
}
$srcFolder = "c:/allraces";
$dstFolder = "c:/liveraces";
foreach ($livePics as $filetocopy) {
exec("copy $srcFolder/$filetocopy $dstFolder/$filetocopy");
}
?>
Appreciate any guidance or if there is an easier way to do this? Any tools, etc. I may not be aware of???