Hi, Im trying to create a database which mirrors folders & files in those folders, the below code works fine, -but- Id like it to be able to update the database as new files are uploaded,
Running the script twice creates duplicate entries, where I only want the new files to be insert, & I cant truncate the database prior, as it will contain other info - Thanks for any help!
<?php
$folderarray = array();
if ($dir = @opendir("gallery/")) {
while (($folder = readdir($dir)) !== false) {
if ($folder != "." && $folder != "..") {
$folderarray[] = $folder;
$filearray = array();
if ($fil = @opendir("gallery/$folder/")) {
while (($file = readdir($fil)) !== false) {
if ($file != "." && $file != "..") {
$filearray[] = $file;
$sql = "INSERT INTO GALLERY SET FOLDER='$folder', FILE='$file'";
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
}
}
closedir($fil);
}
}
}
closedir($dir);
}
?>