Title: Exec-PHP issues with readdir() function&#8230;
Last modified: August 19, 2016

---

# Exec-PHP issues with readdir() function…

 *  Resolved [jderosa3](https://wordpress.org/support/users/jderosa3/)
 * (@jderosa3)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/exec-php-issues-with-readdir-function/)
 * I would like to use a simple PHP script to show all of the images in a directory
 *     ```
       <?php
       	$handle = opendir ('http://www.xxx.com/flash/portfolio/branding/images/');
           while (false !== ($file = readdir($handle))) {
               echo '<img src="'.$file.'"/><br />'.$file.'<br />';
           }
       ?>
       ```
   
 * This throws back a couple of errors:
 * Warning opendir([http://www.xxx.com/flash/portfolio/branding/images/](http://www.xxx.com/flash/portfolio/branding/images/))
   [
   function.opendir]: failed to open dir: not implimented in…. “location of exec-
   php plugin”
 * Any ideas how to get a simple script like this to work?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [16 years, 11 months ago](https://wordpress.org/support/topic/exec-php-issues-with-readdir-function/#post-1063185)
 * Well, writing it so that it’s not broken code would be a good start.
 * The PHP command opendir is trying to open a directory up for reading. However,
   instead of giving it a directory, you gave it a URL. I wouldn’t expect that to
   actually work because a URL is not a directory.
 *  Thread Starter [jderosa3](https://wordpress.org/support/users/jderosa3/)
 * (@jderosa3)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/exec-php-issues-with-readdir-function/#post-1063207)
 * I have tried changing
 * this:
 *     ```
       <?php
       	$handle = opendir ('http://www.xxx.com/flash/portfolio/branding/images/');
           while (false !== ($file = readdir($handle))) {
               echo '<img src="'.$file.'"/>'.$file.'';
           }
       ?>
       ```
   
 * to this:
 *     ```
       <?php
       	$handle = opendir ('../flash/portfolio/branding/images/');
           while (false !== ($file = readdir($handle))) {
               echo '<img src="'.$file.'"/>'.$file.'';
           }
       ?>
       ```
   
 * No luck.. is there a javascript snippet that does what I want?
 * These above still cause errors with the exec-PHP plugin… not sure what going 
   on…
 *  Thread Starter [jderosa3](https://wordpress.org/support/users/jderosa3/)
 * (@jderosa3)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/exec-php-issues-with-readdir-function/#post-1063348)
 * Ok… I finally have it reading file onto the page, but… they come up with broken
   icons as if the graphics are not there… here is my new code:
 *     ```
       <?php
       $dir = "./flash/portfolio/branding/images/";
       //open dir
       if ($opendir = opendir($dir))
       {
          //read dir
       while (($file = readdir($opendir)) !== FALSE)
       {
       if ($file!="."&amp;&amp;$file!="..")
       echo $file."<img src='$dir/$file'><br />";
          }
       }
       ?>
       ```
   
 * Any ideas?
 *  Thread Starter [jderosa3](https://wordpress.org/support/users/jderosa3/)
 * (@jderosa3)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/exec-php-issues-with-readdir-function/#post-1063358)
 * got it to work! Incase anyone needs to know how to do this:
 *     ```
       <?php
       $dir = "./flash/portfolio/branding/images/";
       $jpgs = glob($dir . "*.jpg");
   
       foreach ($jpgs as $jpg) {
           $jpg = substr($jpg, 1);
           echo "<img src='http://www.mydomain.com{$jpg}' /><br />";
       }
       ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Exec-PHP issues with readdir() function…’ is closed to new replies.

 * 4 replies
 * 2 participants
 * Last reply from: [jderosa3](https://wordpress.org/support/users/jderosa3/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/exec-php-issues-with-readdir-function/#post-1063358)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
