Welcome Guest, Not a member yet? Register   Sign In
Path to Assets
#1

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.
Reply
#2

(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?
Reply
#3

(This post was last modified: 06-24-2015, 10:11 PM by InsiteFX.)

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;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(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? 
Reply
#5

Root dir of your website aka document_root
Reply




Theme © iAndrew 2016 - Forum software by © MyBB