PHP Set image source for image tag -


i'm trying use php list of images in folder , display it. here current code:

$images = glob($volumepath."*"); foreach($images $image) {     $path = str_replace('c:\xampp\htdocs\\', '..', $image]);     $path2 = str_replace(' ', '%20', $path);     $file = "<img src=".$path2."/>";     echo $file; } 

right now, can retrieve array of images when try display it, shows generic placeholder image. how show image?

tested giving file path , shows doesn't work php.

try complete code:

$images = glob($volumepath."*"); foreach($images $key => $image) {     $path = str_replace('c:\xampp\htdocs\\', '../', $image);     $path2 = str_replace(' ', '%20', $path);     $file = "<img src='".$path2."'/>";     echo $file; } 

note single quotes in $file variable, modified foreach statement , single $image variable in $path


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -