dimanche 16 novembre 2014

Getting Pictures from folder directory in PHP


Vote count:

0




I have a folder directory set up like this in my htdocs:


claas2/TractorPics\5484474\Recieved\ => and then a bunch of images inside


im using php to put the picture from mysql database where the filepath is stored rather than all the pictures and so that they can be changed easily.


php:



if ( $_REQUEST['rec_pic'] ) {
$order_id = $_POST['rec_pic'];
$sql = "SELECT * FROM `orders` WHERE `active` = '1' AND `order_id` = '$order_id'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$dir = $row['rec_pic'];
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
echo "<div>";
echo "<a href='#'><img src='".$file."' /></a>";
echo "</div>";
}
closedir($handle);
}
}
}


When i echo this out i get an error saying that that file directory does not exist but if i were to do src it in an image it works just fine. What am i doing wrong here?



asked 33 secs ago







Getting Pictures from folder directory in PHP

Aucun commentaire:

Enregistrer un commentaire