Connecting Tech Pros Worldwide Help | Site Map

Directory problem

  #1  
Old August 22nd, 2007, 06:25 PM
Shelly
Guest
 
Posts: n/a
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, 06:45 PM
Shelly
Guest
 
Posts: n/a

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, 07:35 PM
Shelly
Guest
 
Posts: n/a

re: Directory problem


That was it, the old permissions trick.

--
Shelly


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
php upload file to a single directory problem suresh_nsnguys answers 2 June 13th, 2007 04:32 PM
current working directory problem Jeff answers 4 February 19th, 2006 03:15 PM
Working Directory Problem qbproger@gmail.com answers 4 December 8th, 2005 02:45 PM
[BUG] in IIS ? webshared directory problem ! Lloyd Dupont answers 5 November 18th, 2005 10:22 AM
[BUG] in IIS ? webshared directory problem ! Lloyd Dupont answers 2 November 18th, 2005 08:36 AM