I just want to display an image from a directory using PHP. But I could not. I have tried all the below ways.
<?php
/* Getting file name */
$document_root = $_SERVER['DOCUMENT_ROOT'];
$replace = str_replace('/',"\\",$document_root);
$filename = "/excel.png";
//$image_path = $replace."\imagesupload\uploads".$filename;
$image_path = $document_root."/imagesupload/uploads".$filename;
echo $image_path;
//echo '<img src="../admin/upload/' . $display_img . '" width="' . $width . 'px" height="120px"/>';
?>
<html>
<body>
<img src="<?php echo $image_path; ?>" />
</body>
</html>
The above code gives the following output. But the path I gave was correct.
I think this one will help you
<img src="uploads/<?php echo $file.png;?>" />
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments