I deduce the picture from the folder in the browser

<?php $path2 = __DIR__ .'/img/1.jpg'; echo $img = '<img src="'.$path2.'"/>'; ?> 
The picture is not displayed, more accurately displayed as "broken". The path is correct and there is a picture in the folder. In the console, writes "Not allowed to load local resource" Perhaps there are other ways to display a picture?

  • What path to the file? __DIR__ - most likely returns not what you need. - Manitikyl 8:36 pm
  • Yes, if you do not use DIR, then the picture is loaded. - Alexander

1 answer 1

In the headers you need to specify that this is a photo. and output the file like this)) when I did it.

 header('Content-Type: image/jpeg'); $one= stream_get_contents(fopen("http://некоторвый ресурс (сайт)/images/PHP7.jpg","rb")); print_r(print_r);