Affichage des articles dont le libellé est scandir. Afficher tous les articles
Affichage des articles dont le libellé est scandir. Afficher tous les articles

Php Code : How To Show Images From A Folder

Php Code: How To Display Images From A Folder Using Php

________________________________________________________


In this Php Tutorial we will Learn How To Get And Display Only Images From A Directory Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "folder/";
$extensions_array = array('jpg','png','jpeg');

if(is_dir($dir_path))
{
    $files = scandir($dir_path);
    
    for($i = 0; $i < count($files); $i++)
    {
        if($files[$i] !='.' && $files[$i] !='..')
        {
            // get file name
            echo "File Name -> $files[$i]<br>";
            
            // get file extension
            $file = pathinfo($files[$i]);
            $extension = $file['extension'];
            echo "File Extension-> $extension<br>";
            
           // check file extension
            if(in_array($extension, $extensions_array))
            {
            // show image
            echo "<img src='$dir_path$files[$i]' style='width:100px;height:100px;'><br>";
            }
        }
    }
}





                     
php show image







Php : How To Get Image Size From Directory Using Php

Php Code: How To Show Image Width And Height From A Folder Using Php

________________________________________________________


In this Php Tutorial we will Learn How  To Get And Display Images size ( width & height) From Folder Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "images/";

if(is_dir($dir_path))
{
    $files = scandir($dir_path);
    
    for($i = 0; $i < count($files); $i++)
    {
        if($files[$i] != '.' && $files[$i] != '..')
        {
            echo "File Name -> $files[$i]<br>";
            
            $imageSize = getimagesize("$dir_path$files[$i]");
            
            echo " -Image Width : $imageSize[0]<br>";

            echo " -Image Height : $imageSize[1]<br>";

            //jpg or png or gif .........
            echo " -Image Type : $imageSize[2]<br>";

            echo " -Image Width And Height: $imageSize[3]<br>";

            // display the images
            echo"<img src='$dir_path$files[$i]' style='width:100px;height:100px;'><br><br>";
        }
    }
}





                     
php display images width and height






Php : How To Get File Extension From Directory Using Php

Php Code: How To Show Files Extension From A Folder Using Php

________________________________________________________


In this Php Tutorial we will Learn How  To Display Files Extensions From Folder Using Php .

I Use In This Tutorial:

- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "folder/";

if(is_dir($dir_path))
{

    $files = scandir($dir_path);

    for($i = 0; $i < count($files); $i++)
    {

        if($files[$i] !='.' && $files[$i] != '..')
        {

            echo "File Name -> $files[$i]<br>";
            
            $file = pathinfo($files[$i]);

            $extension = $file['extension'];
           
            echo "File Extension -> $extension<br><br>";
        }
    }
}





                     
php files extensions





Php : How To Use Scandir To Show Files Names

Php Code : How To Show Filenames Using Scandir

________________________________________________________


In this Php Tutorial we will Learn How To Use Scandir To Display Files Names From Folder Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "folder/";
if(is_dir($dir_path))
{
    $files = scandir($dir_path);
    print_r($files);
    echo"<br>";
    for($i = 0; $i < count($files); $i++)
    {
        if($files[$i] != '.' && $files[$i] != '..')
        {
            echo "File $i -> $files[$i]<br>";
        }
    }
}




                     
php using scandir