Need help getting application base path |
[eluser]mmatos[/eluser]
Hello, I'm working on my 2nd CI application, and my goal is to make my applications "ultraportable" - basically upload and run. Right now, I'm working on an image upload/delete administration section. When a user deletes an image, a function called deleteImage in my model will get called: Code: function deleteImage($image_id) { My problem is in this: Code: $filedelete = $imagepath . $imagetodelete; I need to get the FULL path to that image starting from root. I don't see a function in the CI documentation that returns the applications base directory (eg: c:\wamp\www on my dev box, or /home/user/www on prod box.) For portability reasons, I do not want to hard code it. I'm sure I'm just missing something. Thanks.
[eluser]mmatos[/eluser]
Thanks, but I am looking for the local file system path, not the URL to the application.
[eluser]mmatos[/eluser]
It looks like there's been a debate in the past over the exclusion of this. I found these two related threads, exactly what I needed: http://ellislab.com/forums/viewthread/45782/ http://ellislab.com/forums/viewthread/47572/
[eluser]louis w[/eluser]
By local file system path, do you mean the path to the current file? Try $_SERVER["SCRIPT_FILENAME"]
[eluser]Yunus Khan[/eluser]
You can create easily documentation path / base path easily.. Code: /*
[eluser]dr.fux[/eluser]
Hello everybody I just came over the same problem, an i realized, that it wasn't really one for me. Correct me if I'm wrong, but for me it works just consider the base_path is just the working directory of the running CI script, beacause the index.php file is stored in that directory. So why not consider Code: $base_path = "." This would have the conclusion, that a subdirectory of the base_path could be accessed by something like that: Code: $images_dir = "images/"; //means http://www.urdomain.com/any_directory/images/ Are there any cases where the working directory of a CI application would change during system execution? greets, sniffer |
Welcome Guest, Not a member yet? Register Sign In |