Search code examples
cakephpabsolute-pathbase-path

Getting base directory in CakePHP


I am working on a CakePHP project. Here, I have to upload a file and then move that file to a specific folder. Uploading is working well, but I can't move it to the folder I want. Is there any function or something in CakePHP to move the uploaded file ?

Currently I am using PHP's core function move_uploaded_file(). This function requires absolute path for both source & destination, not the http://localhost/...., I tried it, but it didn't work. So, do you know how do I get the Base Directory/Absolute Path of my application ? This would be like : C://wamp/www/project_folder/.......


Solution

  • The constants that Cake generates (or hands you over...) are documented in the Global Constants and Functions.

    Using Cake's global APP seems the way to go (unless you don't want to move the files in the APP/ folder).