Welcome Guest, Not a member yet? Register   Sign In
Best way of retrieving full server paths.
#1

[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?
#2

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




Theme © iAndrew 2016 - Forum software by © MyBB