Welcome Guest, Not a member yet? Register   Sign In
Image display and .htaccess
#1

[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!
#2

[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.
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB