CodeIgniter Forums
Getting absolute path for uploading a file - 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: Getting absolute path for uploading a file (/showthread.php?tid=14089)



Getting absolute path for uploading a file - El Forum - 12-17-2008

[eluser]jaswinder_rana[/eluser]
Hi:

I am trying to upload a file with upload.php CI library. Its giving me wrong upload path error.

My structure is

system
- applicaiton
-- views
public_html
- index.php
- public
-- upload
--- YYYY
---- MMDD

How can I refer to "upload" directory from my controller? My solutions seem to be

- Use absolute path from controller; don't want to make it fix
- Store absolute path in my own config file and include it
- Somehow try to calculate the path automatically

I was hoping that there is a way that I can get my path for index.php (in this case /some/path/public_html). Is there a way in CI to do that?

I don't want to have to change it everytime I change servers with different paths.

Please help


Getting absolute path for uploading a file - El Forum - 12-18-2008

[eluser]mihailt[/eluser]
http://www.php.net/manual/en/function.realpath.php ?


Getting absolute path for uploading a file - El Forum - 12-18-2008

[eluser]John_Betong[/eluser]
 
 
I always echo getcwd();, see what is displayed and set the new path accordingly.