CodeIgniter Forums
Path to Assets - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Path to Assets (/showthread.php?tid=62255)



Path to Assets - soonerdm - 06-24-2015

I'm not sure what we are doing wrong but I cannot pull any images, css or js from the directories I have created in the MVC directory

/main
/mvc
/mvc/images
/mvc/js
/system

If I link them directly <img src="http://ip_address/~sandbox/images/home.png">
Nothing

$this->load->helper('url');
echo "<img src=".base_url('images/home.png').">";

doesn't work either but it does echo the html <img src="http://ip_address/~sandbox/images/home.png">

It appears the helper('url') method is working correctly but still cant see the image its pulling.

Is there something we missed in configuration? Something thats not in .htaccess we need?

Fresh install of CI 3 on SUSE12 with Oracle 11g.


RE: Path to Assets - skunkbad - 06-24-2015

(06-24-2015, 01:19 PM)soonerdm Wrote: I'm not sure what we are doing wrong but I cannot pull any images, css or js from the directories I have created in the MVC directory

/main
/mvc
/mvc/images
/mvc/js
/system

If I link them directly <img src="http://ip_address/~sandbox/images/home.png">
Nothing

$this->load->helper('url');
echo "<img src=".base_url('images/home.png').">";

doesn't work either but it does echo the html <img src="http://ip_address/~sandbox/images/home.png">

It appears the helper('url') method is working correctly but still cant see the image its pulling.

Is there something we missed in configuration? Something thats not in .htaccess we need?

Fresh install of CI 3 on SUSE12 with Oracle 11g.

You might want to look in the access logs. Is it just a 404 error, or something else? What does your current /.htaccess look like?


RE: Path to Assets - InsiteFX - 06-24-2015

Also make sure your asset folder is in the root with index.php the CodeIgniter folders are protected.

You can also create your asset_helper.php

PHP Code:
/**
 * Helper asset_url()
 * ------------------------------------------------------------------------
 * @access    public
 * @param    string
 * @return    string
 */
if ( ! function_exists('asset'))
{
    function 
asset($uri)
    {
        
$_ci =& get_instance();
        return 
$_ci->config->base_url('assets/'.$uri);
    }


You can use the above code to create any type of asset you need. img, css etc;


RE: Path to Assets - soonerdm - 06-25-2015

(06-24-2015, 04:28 PM)skunkbad Wrote:
(06-24-2015, 01:19 PM)soonerdm Wrote: I'm not sure what we are doing wrong but I cannot pull any images, css or js from the directories I have created in the MVC directory

/main
/mvc
/mvc/images
/mvc/js
/system

If I link them directly <img src="http://ip_address/~sandbox/images/home.png">
Nothing

$this->load->helper('url');
echo "<img src=".base_url('images/home.png').">";

doesn't work either but it does echo the html <img src="http://ip_address/~sandbox/images/home.png">

It appears the helper('url') method is working correctly but still cant see the image its pulling.

Is there something we missed in configuration? Something thats not in .htaccess we need?

Fresh install of CI 3 on SUSE12 with Oracle 11g.

You might want to look in the access logs. Is it just a 404 error, or something else? What does your current /.htaccess look like?


It is a 404 error .htaccess in the root of Main is this

PHP Code:
RewriteEngine On
RewriteBase 
/~sandbox/
RewriteCond %{REQUEST FILENAME} !-f
RewriteCond 
%{REQUEST FILENAME} !-d
RewriteRule 
^(.*)$ index.php/$[L





Insite when you say root. Root of what? 



RE: Path to Assets - CroNiX - 06-25-2015

Root dir of your website aka document_root