Directory problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
When I upload pictures I put them into a directory structure such as


where 1000 is the account number of the customer and 1 is the agentID of the  
particular customer employee who requested it be put there.

To view the files I do a directory search (code after this explanation) to  
build a list, $filelist,  that I will put up in the html area with a <?php  
echo $filelist ?>

The result of all this is that it finds the one file that is that directory  
(Jon.jpg) and prints it out the link and the name (see code below).  
However, when I click on it to actually view the picture, it gives a page  
not found.  What I don't understand is why this is happening when I got the  
name from the directory search.

Data in the form
$TOP =" /";
$accountNumber = 1000;
$agentID = "1";
$authCode = "something";    //  This is for later when I check against a  
database to validate permissions)

$accountNumber = $_POST['accountNumber'];
$agentID = $_POST['agentID'];
$authCode = $_POST['authCode'];

$empty = (strlen($accountNumber) == 0) && (strlen($agentID) == 0) &&
      (strlen($authCode) == 0);
$ok = false;
if (isset($_POST['viewPic']) && !$empty) {
 $ok = true;
 $dir = "photos/" . $accountNumber . "/" . $agentID;
 if ($handle = opendir($dir)) {
   while (false !== ($file = readdir($handle))) {
     if ($file != "." && $file != "..") {
      $filelist .= '<a href="' . $TOP . $dir . "/" .$file . '">' .
                $file . "</a><br>";


The view source gives:
<a href="">Jon.jpg</a>

So, the directory search finds it to build the link, but I a get a page not  
found on the click.  Any ideas?  (It is probably something so simple that it  
is a DUH!, but I have not been able to see it).


Re: Directory problem

Quoted text here. Click to load it

The problem is not in the code I presented. I ran a simple test by creating  
a test.htm that simply echoed "testing".

I then tried:

after putting it in all those places.  Only the last one did not give me a  
page not found, so I suspect it has something to do with access rights to  
photos directory.

Sorry for troubling you.


Re: Directory problem

That was it, the old permissions trick.


Site Timeline