Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Image from above root
  • hello,

    I'm trying to display images that are stored outside the root dir.
    Currently I am doing this by calling a script that gets the image details and sends back the header of a jpeg and then using that output in an img src tag.

    image_getter.php
        $contents = file_get_contents('../images_thumbs/thumb-'.htmlentities($_GET['i'], ENT_QUOTES, 'UTF-8').'.jpg');
        header('Content-type: image/jpeg');
        echo $contents;

    page_to_show_image_on.php
    <img src="./image_getter.php?i=<?php echo strtr($filename['encoded_file_name']); ?>"  width="280" height="280" border="0" />

    Do I need to continue to use this or can I skip the image_getter.php and use:
    <img src="<?php Image::load('path/to/image/file.jpg')->output('jpeg');?>" width="280" height="280">

    When I try this, the entire screen grays out and it seems as if only the image is trying to be sent back and not in the img tag.

    Any suggestions would be helpful.

    Thanks.

    (on a side note, is there a way to be notified by email when someone replies to a post? I only get an email when I'm mentioned in  a post)


  • The entire point of placing the code outside of the docroot is that no browser can access the files anymore. This implies that you can't put any files there that the browser MUST be able to access.

    So you have to either use a technique like you do now, make them accessable inside the docroot, for example using symlinks, or use a rewrite rule to access the files, for example by mapping /public/assets/module to /fuel/app/modules/module/assets ...

    If you click on "Profile", you can specify which notifications you want by clicking on "My preferences".

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion