Welcome Guest, Not a member yet? Register   Sign In
How to bring images folder out from CI Architecture.
#1

[eluser]Arun Joshi[/eluser]
Hi,

Am a beginner in CI, I have completed my site's some pages in CI, But now me facing a problem with image path. I am using wamp server
and this is my site folder.

Code:
E:\wamp\www\technoneeds


am accessing site by this url (my base url)
Code:
http://localhost/technoneeds/


I have added some imgages in the following folder.

Code:
E:\wamp\www\technoneeds\system\application\images


I want to display an image say 'pic1.jpg' in the above folder in posts controller, ie (http://localhost/technoneeds/posts/).
How can I set the path in img tag.
I dont like to add a path like 'system\application\images' in img tag.

How can I set a image path like this
Code:
http://localhost/technoneeds/images/pic1.jpg




This is my current .htaccess file.

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

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /system/index.php?/$1 [L]

    #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 ^(.*)$ /technoneeds/index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#2

[eluser]Dam1an[/eluser]
You can either use the img function in the http://ellislab.com/codeigniter/user-gui...TML helper or use the base_url function to give your images an absolute path
#3

[eluser]Arun Joshi[/eluser]
I have tried both methods,
The image path is 'http://localhost/technoneeds/imgs/josh.jpg',
but the image is not showing there, I think It is redirected by .htaccess file.
How can I rewrite it?
#4

[eluser]Dam1an[/eluser]
This is my htaccess
Code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico|license.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

The first rewrite condition means anything that isn't index.php, the image directory etc, so add a similar line to yours
#5

[eluser]Arun Joshi[/eluser]
Thanks Dam1an,

Your .htaccess file solved my problem.

Thank u verrrrrrrrry much.... :coolsmile:
#6

[eluser]Dam1an[/eluser]
you're welcome (although my htaccess was based on Daniels killer htaccess lol)




Theme © iAndrew 2016 - Forum software by © MyBB