2/21/2011

How to get absolute path of base directory in magento

While uploading a file in magento It's necessary to write the absolute path of your magento path, otherwise it will not upload. you can get your site absolute path from php.ini file, You can place this path by hardcording but later if you think to move your site to another host then the path will be change, So to make your absolute path dynamic or get the proper path in which your magento Installed, write the following code

<?php echo Mage::getBaseDir('media') . DS ;?>

It will definately work,

1 comment:

  1. thanks for this great tip, but pls, help me here, I'm a total newbie.

    Write the code where?

    ReplyDelete