0

I am trying to make gallery which displays all the .jpg files in some local directory, but it makes me problem.

   <?php

   $directory = "img/";   
   $images = glob($directory."*.jpg");
   foreach($images as $image)
   {
       echo '<img src="file://'.$image.'" /><br />'
   }
   ?>

Somehow path to jpg file is not correctly passed to the src attribute, where I am wrong?

1
  • Assuming you get a broken image icon, what does right clicking say is the path that it's trying? What does "View source" on the browser show? Do modern browsers even allow file:// anymore? And you might want to have file://img/ as the path or whatever the full, absolute path is. Commented Nov 25, 2020 at 23:13

1 Answer 1

1

Just remove the file:// on the src.

from

echo '<img src="file://'.$image.'" /><br />';

to

echo '<img src="'.$image.'"/><br />';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.