Connecting Tech Pros Worldwide Help | Site Map

Directory problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 22nd, 2007, 05:25 PM
Shelly
Guest
 
Posts: n/a
Default Directory problem

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

photos/1000/1/Jon.jpg

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 ="http://www.mywebsite.com/";
$accountNumber = 1000;
$agentID = "1";
$authCode = "something"; // This is for later when I check against a
database to validate permissions)

Code:
<?php
$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>";
}
}
closedir($handle);
}
}

?>

The view source gives:
<a href="http://www.mywebsite.com/photos/1000/1/Jon.jpg">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).

--
Shelly



  #2  
Old August 22nd, 2007, 05:45 PM
Shelly
Guest
 
Posts: n/a
Default Re: Directory problem

"Shelly" <sheldonlg.news@asap-consult.comwrote in message
news:13cos8tbmnkvjc7@corp.supernews.com...
Quote:
When I upload pictures I put them into a directory structure such as
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:
http://www.myserver.com/photos/1000/1/test.htm
http://www.myserver.com/photos/1000/test.htm
http://www.myserver.com/photos/test.htm
http://www.myserver.com/test.htm

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.

--
Shelly


  #3  
Old August 22nd, 2007, 06:35 PM
Shelly
Guest
 
Posts: n/a
Default Re: Directory problem

That was it, the old permissions trick.

--
Shelly


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.