www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP Opendir problem

  1. #1
    Join Date
    Sep 2011
    Posts
    1

    PHP Opendir problem

    Hi there.

    PHP is telling me there is no such file or directory at the specified location. This is rubbish.

    Code:
    <?php
    	function insertGalleryImages($path){
    		// echo getcwd();
    		$index = array();
    		if($folder = opendir($path)){
    			$pic_types = array("jpg", "jpeg", "gif", "png");
    			while($file = readdir($folder)){
    				if(in_array(substr(strtolower($file), strrpos($file,".") + 1),$pic_types)){
    					array_push($index,$file);
    				}
    			}
    		
    			closedir($folder);
    		}
    		
    		return $index;
    	}
    ?>
    Error message:

    Warning: opendir(images/projects/Illustration/Animals/thumb): failed to open dir: No such file or directory in /Users/Alex/Sites/RosalindMundie/insert_gallery.php on line 5.

    • I have checked current directory with getcwd()
    • I have checked permissions, all have full permissions
    • I have checked pwd in terminal and the directory is the same
    • I have tried prepending the path name with './' and even '../' incase it is looking in the wrong place


    Not sure what else to do! Anyone help?

    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    For a sanity check, try using a full, absolute path-name, e.g.:
    PHP Code:
    insertGalleryImages('/Users/Alex/Sites/RosalindMundie/images/projects/Illustration/Animals/thumb'); 
    (At least that appears to be the desired location based on the info in the error message.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles