Reply to Directory problem

Your name:

Reply:


Posted by Shelly on 08/22/07 17:23

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация