PHP移动图像功能

need help with this.

function move_images($dir_source,$dir_target){
    $files = glob($dir_source);
    foreach($files as $file){
        if(is_file($file))
        copy($file,$dir_target.basename($file));
        unlink($file);
    }
    return true;
}
move_images('temp/*','../images/');

I got this message:

Warning: Invalid argument supplied for foreach() in /home/scrapboo/public_html/inc/functions.php on line 75

Actually, it's working good when there's a files in "temp" directory. So, how to skip this when temp is empty?

Thanks

Actually, it's working good when there's a files in "temp" directory. So, how to skip this when temp is empty?

No need to check if the directory/array is empty, if it would be it just won't iterate through your foreach loop.

But you have to make sure that your directory is readable, you can check this with is_readable().