Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

linux/php image path on read directory

Posted on 2011-03-15
2
Medium Priority
?
605 Views
Last Modified: 2013-12-13
I figured out how to access folder contents on a Windows (needs full path) but cannot get it on a linux system.  It's on the localhost - you'll see the folder path.
Code is attached:

<?php

$account="account";
$adImage="Images";
$directory = "C:/var/www/Planroom/DataBase/account/Ads/Images";
// tried "/var/www/Planroom/Database/account/Ads/Images" with and without initial slash
// also "/Database/account/Ads/Images" with and without initial slash
$handler = opendir($directory);

if(file_exists($directory)) {

    $results = Array();
    $x=0;

    while ($file = readdir($handler)) {
       if ($file != "." && $file != "..") {
        $results[$x] = $file;
        $x+=1;
      }
    }
    closedir($handler);
echo($x);  // $x=0
}
?>

Open in new window

0
Comment
Question by:dcass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 2000 total points
ID: 35140560
Put this line on top of your file:

phpinfo();

Open in new window


and when the file is executed (opened in browser) you search for DOCUMENT_ROOT to how the path to this file is constructed. Try to adjust that in a way to reach you desired location.
0
 
LVL 8

Expert Comment

by:mostart
ID: 35140580
Full path with slash at beginning should work in general. Maybe your PHP is configured not to let you access the directory or the directory access rights are not correct.

Do you get an error message ?

Try adding this line to your file before opendir if you do not see any error message:
error_reporting(E_ALL);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question