Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:36:13+00:00 2026-06-11T13:36:13+00:00

I’ve got problems with sorting out the paths in my app. I’m using APPPATH

  • 0

I’ve got problems with sorting out the paths in my app.

I’m using APPPATH function to read/write my images’s string path in my db. The problem is that the APPPATH puts the function after the controller

here is my function for getting the css

<link rel="stylesheet" type="text/css" href="<?php echo '../' . APPPATH.'_data/css/style.css'; ?>" />

and when i go to http://localhost/project/index.php/home it works great
css links to http://localhost/project/application/_data/css/style.css which is correct

but then I have this other controller

http://localhost/project/index.php/member/index/1

The css file path has to be

href="<?php echo '../../../' . APPPATH."_data/css/style.css"; ?>"

because other wise my link to the css goes to

http://localhost/project/index.php/member/application/_data/css/style.css

I’m using a simple template structure where i have my header/content/footer in an include sub-folder in views and I’m sending data to the content. Pretty standard stuff. I just don’t get why the APPPATH does not work as if when called it gives me the PATH to the APPLICATION folder regardless the class that’s been used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:36:15+00:00Added an answer on June 11, 2026 at 1:36 pm

    APPPATH is really for system files, not frontend assets. It’s the path to your application folder, and that’s what it should be used for. ../relative/paths rarely work well in Codeigniter since they are relative from the current URL (not the view file). This is really a mess you’re getting into.

    Simple solution is to use base_url() instead, but if you want shorter paths, this is what I use:

    define('BASE_URI', str_replace('index.php', '', $_SERVER['SCRIPT_NAME']));
    

    In most cases, the result will be /, but this will account for CI installations in sub directories. For you, it should return /project/.

    It’s not recommended to keep static files like CSS and images mixed into your application files. Most people create a directory called assets or public to store them.

    <link rel="stylesheet" href="<?php echo BASE_URI.'public/css/style.css'; ?>" />
    <link rel="stylesheet" href="<?php echo base_url().'assets/css/style.css'; ?>" />
    

    If you really need to store assets in your application folder, then just drop all the relative paths. You don’t need them since APPPATH is absolute:

    <link rel="stylesheet" href="<?php echo APPPATH.'_data/css/style.css'; ?>" />
    

    That should work from everywhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
We're building an app, our first using Rails 3, and we're having to build
i got an object with contents of html markup in it, for example: string
I am using Paperclip to handle profile photo uploads in my app. They upload
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.