Jump to content

PHP does not show pictures

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Turboorav

Turboorav

    Newbie

  • Members
  • Pip
  • 7 posts
I have a problem, this script I wrote takes a folder and then shows the pictures in that folder on the screen. It works in phpdesigner and it works in IE (except one picture), it does not show any pictures in Firefox and it doesn't show even that there SHOULD be pictures in Chrome.

HERE is the gallery with screenshots. There are pictures with Chrome, Firefox, IE and phpdesigner. It seams that the one picture, that is not showed in IE is "png" format, other are "jpeg".

<?php
class DirSisu{
    private $dirAdress; 
    private  $aadress;   
    private $dir;       //the exact address of the files  dir
   
    //Konstruktor
    function __construct($kataloog){
         $this -> dirAdress = getcwd(); 
        $this -> dir =  $this -> dirAdress.'/'.$kataloog; 
        $this -> aadress =  scandir($this -> dir); //adds files names into an array
    }
    
    //Shows the filenames that are in the directory
     function valjasta (){
        for($i = 2; $i < count($this ->  aadress); $i++){
            echo $this -> aadress[$i]."<br  />";
        }
    }
   
    //Shows the pictures on the  screen
    function kuvaPildid(){
         for($i = 2; $i <  count($this -> aadress); $i++){
            $a = $this ->  dir.'/'.$this -> aadress[$i]; //The exact address of the picture
             if(!is_dir ($a)){   //contorls if the file is not a folder
                 echo "<img src='$a' width='400' hspace='20'  vspace='20' align='center' />";
            }
        }
    }
}

$isend  = new DirSisu('kataloog');
$isend -> valjasta();
$isend ->  kuvaPildid();

?>


#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
If you view the html source in Chrome, does your <img src.. code show up?

#3
Turboorav

Turboorav

    Newbie

  • Members
  • Pip
  • 7 posts
Yes it does, I already actually understood what was wrong. I didn't need the "full path" at all, I only needed the directory path from the script file and the
getcwd();
method was wrong one to use also.

Topic can be locked.