Hey all. I have also the following code with functions which send the file to the data base with Insert createCallAttachment is a function to send data to database. The functions are fine and I just have here the code which compares the files in a folder according to the date and time they are entered(filemtime). for some reason in the loop the files are sent to the data base more than once and do u have any clue? oh my God is my question clear with my bad english?
function compare($a,$b){
return $b[1]-$a[1];
}
function read_dir($path) {
$files = Array();
if ($handle = opendir($path)) {
while (false !== ($fileSName = readdir($handle))) {
if ($fileSName != "." && $fileSName != "..") {
$files[] = Array($fileSName,filemtime($path.$fileSName));
}
}
closedir($handle);
}
return $files;
}
$files = read_dir($path);
usort($files,"compare");
for($i=0;$i<$num_of_uploads;$i++){
$filename = $files[$i][0];
echo "$filename";
if( !callAttachmentExists( &$connection, $call_id,$filename )) {
createCallAttachment( &$connection, $call_id, $filename );
}}