This is the code: $dir = "wallpapers/"; setWatermarkToDir($dir); function setWatermarkToDir($dir){ $dh = opendir($dir); echo "Dir: $dir <br/>"; while (($file = readdir($dh)) !== false) { echo 'Unknown: ' . $file . "<br/>"; if(strlen($file) > 2) { // check to see if it is a file if(is_file($file) == true) { echo "File: $file <br/>"; setWatermarkText('Img4u.com',$dir . $file,$dir . $file); } // check if it is a directory if (is_dir($file) == true) { echo "Opening directory $dir . $file / <br/>"; setWatermarkToDir( $dir . $file . '/'); } } } closedir($dh); } PHP: what could be the reason for this? Also when I read the files in directory the first two is "." and "..", y is that? (This is the reason for strlen > 2)
The . refers to the current directory and the .. to the parent directry of your current directory. And i tried the code and everything runs fine an my server? What errors are you experiening? // btw: take a look at scan_dir function. This functions reads a directory and return all items in it as an array so you do not need to read the directory manual and work with file handles
thanks I solved this. THe problem was that is didn't give the full path for the $file in the function