Welcome Guest, Not a member yet? Register   Sign In
how to load images inside application folder?
#1

[eluser]runrun[/eluser]
I have img folder inside application folder. It seems that that doesn't allow to load the images.

I tried this <img src="/application/img/logo.png" /> it doesn't work. What should I do ?

My folder structure is like this

Code:
system
application
  controllers
  img
  css
  views
#2

[eluser]TWP Marketing[/eluser]
I would advise moving your assets (js, css, img, etc.) up to the same level as System and Application.

If you don't want to or cannot do this due to design considerations, then check the write permissions on your image directory.
#3

[eluser]pickupman[/eluser]
Check the .htaccess file in /application/.htaccess, it is probably set to Deny from all . You can use a conditional <FileMatch> statement above it to allow your img/css folders.
Code:
# deny *everything*
<FilesMatch ".*">
  Order Allow,Deny
  Deny from all
</FilesMatch>

# but now allow just *certain* necessary files:
<FilesMatch ".*\.(js|JS|css|CSS|jpg|JPG|gif|GIF|png|PNG|swf|SWF|xsl|XSL)$">
  Order Allow,Deny
  Allow from all
</FilesMatch>
#4

[eluser]runrun[/eluser]
My htaccess file is like this
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI}\\/%{HTTP_HOST}/www. ^/+(.+/)?[^.]*[^/]\\(/)([^w][^w][^w][^.].*/(www\.)¦.*)$ [OR,NC]
RewriteCond %{HTTP_HOST}/www. ^(/)?(/)?([^w][^w][^w][^.].*/(www\.))$ [NC]
RewriteRule ^ http://%4%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|chat|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]

it doesn't look like it restricting access to any particular file, does it ?
#5

[eluser]InsiteFX[/eluser]
pickupman is talking about the .htaccess file in your application folder!

InsiteFX
#6

[eluser]pickupman[/eluser]
[quote author="InsiteFX" date="1309082649"]pickupman is talking about the .htaccess file in your application folder!

InsiteFX[/quote]

Looks like you have posted in the .htaccess file in root (/). In recent updates with CI Reactor a .htaccess file was added inside of the application folder. Another security measure for those that have the application folder inside of their web root and don't have:
Code:
if( !defined('BASEPATH') ) die('Direct access scripts is prohibited!');

That way someone can't access a file directly without it being correctly processed by CI and the /index.php file.
#7

[eluser]runrun[/eluser]
There is no ht.access in my application folder. Is it because I'm using CI 1.7.2 ?
#8

[eluser]pickupman[/eluser]
[quote author="runrun" date="1309126221"]There is no ht.access in my application folder. Is it because I'm using CI 1.7.2 ?[/quote]

I would first strongly encourage upgrading to 2.0.2, as a lot of bugs have been fixed since 1.7+. It's also faster in many aspects, as it has dropped support for PHP4.

On your issue with the images, what does "doesn't work" mean? Are you getting an Apahce prohibited error, an Apache 404, CI 404?

Your /.htaccess file shows it checking if file really exists before sending the URI request to index.php, so it looks like you are good there.




Theme © iAndrew 2016 - Forum software by © MyBB