CodeIgniter Forums
Check if file exists? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Check if file exists? (/showthread.php?tid=47857)



Check if file exists? - El Forum - 12-25-2011

[eluser]Unknown[/eluser]
Hi forum.

I have added the following lines in my config file for ease of acces:

Code:
$config['css'] = $config['base_url'].'assets/css/';
$config['js'] = $config['base_url'].'assets/js/';
$config['images'] = $config['base_url'].'assets/images/';

I have a "master-layout" where I include the header, footer and main content. To include only the necessary .css code I'm trying this:

Code:
$css_path = assets('css').$pagetitle.'/'.$pagetitle.'.css';
if(file_exists($css_path)) { echo '<link rel="stylesheet" href="'.$css_path.'" type="text/css" media="screen, projection" />'; }

But the "file_exists" function can't find the specified path (and I have checked it.)

In another thread, "fopen" was used, but if I use it and the file does not exist I get a php-error.

Can someone please clearify why the "file_exists"-function won't work?

Kind regards.