I’m writing a PHP program that will get an image from the filesystem and display it on the returned page. The catch is that the file isn’t stored in the /var/www directory. It’s stored in /var/site/images. How can I do this? Do I have to read it into memory with fopen, then echo the contents?
Share
Use
fpassthruto dump the contents from the file system to the output stream. In fact the docs forfpassthrucontains a demo of exactly what you’re trying to do: https://www.php.net/fpassthru