CodeIgniter Forums
Best way of retrieving full server paths. - 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: Best way of retrieving full server paths. (/showthread.php?tid=11396)



Best way of retrieving full server paths. - El Forum - 09-07-2008

[eluser]Bramme[/eluser]
I was just wondering: what would be the best way to get a full server path to something?

I'll explain myself better with an example: I'm working on a photo gallery which I'm developing on my personal computer, I'll put it online later. Now as a part of my script, I need to make some thumbnails.

I've got a function create_thumb($folder, $image). $folder is the subdirectory of my $this->main_dir, which is a config variable, $image is the file name. So I could construct a path like $this->main_dir.$folder.'/'.$image.

But the image_lib needs a relative or absolute path, not an URL. I always try to use absolute paths, as relative can give you serious headaches, but I can't stick base_url() on it, because that would make it an URL, not a server path.

I could stick $_SERVER['DOCUMENT_ROOT'] to it, but that wouldn't handle everything if CI is in a subfolder...

Am I missing something?


Best way of retrieving full server paths. - El Forum - 09-07-2008

[eluser]xwero[/eluser]
use something like
Code:
define('GALLERY', dirname(FCPATH).'/gallery');
FCPATH is the full path to the index.php