CodeIgniter Forums
Image display and .htaccess - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Image display and .htaccess (/thread-57344.html)



Image display and .htaccess - El Forum - 03-07-2013

[eluser]julian0008[/eluser]
Here is my line of code below which displays an image from the uploads folder within the application folder using base_url()
Code:
<div id = "picture">
  <img id = "main" src = "&lt;? echo base_url() . 'application/uploads/default.jpg'; ?&gt;" alt = "profilepic"/>
</div>

And this is my htaccess file located at the root directory of my CI installation

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /tutorial/

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

The problem is the image does not display. Instead, it displays the alt text. Is there something wrong with my htaccess? Did I miss something? Thanks for any help in advance!


Image display and .htaccess - El Forum - 03-07-2013

[eluser]Aken[/eluser]
There is an .htaccess file in the application folder that prevents you from putting static assets such as images in it. It's best to place your uploads folder at the root of your application, e.g. the folder where index.php is.


Image display and .htaccess - El Forum - 03-08-2013

[eluser]julian0008[/eluser]
thank you sir Aken for the replyill go try it now