I have the following. A website that create temporarily images in the /tmp folder on the Linux server. The reason why I store it within this folder is since these images need to be cleared once in a while and it’s so much easier just to clear the tmp directory using tmpwatch. Now my issue is to display the image within my browser?
Code
<img src="/tmp/3d34636.png" alt="image" />
I’m running Centos with PHP
The trouble here, is that this img tag will be processed by the browser (the client). This client does not have access to the filesystem of the HTTP server.
Therefore, you have either to define the /tmp directory to be a valid location of your HTTP server, using the files in /tmp/ directory (but note that it would serve any other file contained in this directory, potentialy a security risk).
Or you store these generated images in a subdirectory that is already served by your HTTP server.
It may also be possible to define this /tmp location on the server to be served by a script that would analyse the URL containing the image filename. This script would then open the file in /tmp/ and serve it.