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
Post a Comment