Jump to content


Photo

Relative Directory Reading not working


  • Please log in to reply
2 replies to this topic

#1 randomname

randomname
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 June 2006 - 09:10 AM

Well I am new to php so this is probably an easy fix but it is not working for me

Here is my code
<?php
$path = $_GET['path'];
$path = 'site_images/galleries/',$path;
if (!$path or !is_dir($path)) $path='mp3';
$dir_handle = opendir($path) or die("Unable to open $path");
$files=array();
while ($file = readdir($dir_handle)) 
{
     if ($file != '.' and $file != '..' and strtolower( substr ( $file, -4, 4 ) ) == ".jpg" )
    $files[]=$file;
}
$i=0;

if(count($files)) {
    sort ($files);
    foreach ($files as $file) {
$i++;
        list( $w, $h ) = GetImageSize( $path . '/' . $file );
        echo '&image',$i,'=', $file,'&img_w',$i,'=', $w,'&img_h',$i,'=', $h;
    }
}
closedir($dir_handle);
?>
This is the line giving me the problems
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$path = 'site_images/galleries/',$path;[!--colorc--][/span][!--/colorc--]

I want to use the $_GET as the directory within "site_images/galleries/" but this isn't working for me if I take out that line it works great but I have to put path=site_images/galleries/gallery1 which I don't want to do

Any help is greatly appreciated I have been messing with this for hours

Thanks

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 23 June 2006 - 12:07 PM

Try replacing the comma with a period.
$path = 'site_images/galleries/'.$path;


#3 randomname

randomname
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 June 2006 - 04:50 AM

Actually right after I posted this I figured it out I used

$path = "site_images/galleries/$urlpath";

So this works as well

Thanks for the help though




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users