in reply to Displaying Image located outside web server dir

Is there any reason why you need perl to do this? HTML would work just fine, all you'd have to do is put the URL or absolute path of the file in the IMG src= attribute.
meh.
  • Comment on Re: Displaying Image located outside web server dir

Replies are listed 'Best First'.
Re^2: Displaying Image located outside web server dir
by jhourcle (Prior) on May 08, 2005 at 19:13 UTC

    There are actually valid times to do this. (most people would never have a reason to, though).

    In the case in question, the issue was that the files weren't in a directory that the webserver was directly serving. Of course, if that's the only issue, you can just symlink it in to a directory that is being served, or just map the images directory in the webserver.

    Some people use this trick to ensure that someone can't link directly to their images. (eg, you have an image on your website that other people are trying to place in an <img> on their website. Or, any other time that you might have the image vary based on some parameter (randomizing, adjusting by time, or preventing it from being viewed too often is the main reason -- most other things, such as password protection, or varying by accept language, IP range or HTTP_REFERER you can handle through URL rewriting or otherwise through the webserver).

    In some situations, you it might be that the images are actually stored in a database, and not just a file system, so you need to handle the retrieval. In some situations, you might also store the files compressed, and decompress them as they're requested. (this might not be advantageous for most file formats, but you can use this for other types of files, as well.)