SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple problem - directory?

    i have this code:
    Code:
    <?php
    
    $images = "/images/thumbnail";
    $big    = "/images/main";
    $cols   = 2;
    
    if ($handle = opendir($images)) {
       while (false !== ($file = readdir($handle))) {
           if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
               $files[] = $file;
           }
       }
       closedir($handle);
    }
    
    $colCtr = 0;
    
    echo '<table width="100%" cellspacing="3"><tr>';
    
    foreach($files as $file)
    {
      if($colCtr %$cols == 0)
        echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
      echo '<td align="center"><a href="' . $images . $big . $file . '"><img src="' . $images . $file . '" /></a></td>';
      $colCtr++;
    }
    
    echo '</table>' . "\r\n";
    
    ?>
    and keep receiving the errors:

    Warning: opendir(/images/thumbnail) [function.opendir]: failed to open dir: No such file or directory in /home/tim783/public_html/ant/thirdproj/gallery.php on line 80



    Warning: Invalid argument supplied for foreach() in /home/tim783/public_html/ant/thirdproj/gallery.php on line 93


    i have changed $images = "/images/thumbnail"; to the full url and anything i can think of but no luck...any helpers?

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try relative paths to the directories:
    PHP Code:
    <?php
        $r 
    opendir(realpath(dirname(__FILE__)).'/../images/thumbnails/');
    ?>
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2008
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry im a novice and that wasnt of help, thanks for your reply though


Bookmarks

Posting Permissions

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