how can i set to the top directory (i.e. public_html/folder)?

I have tried $_SERVER['DOCUMENT_ROOT'] without luck.

define('JPATH_BASE', dirname(realpath(__FILE__)). '/folder' );

Recommended Answers

All 6 Replies

Please explain your question more in details so we can help you better. From your question i understand you have path issue, http://yourdomain.com this is your public_html directory but if you hosted your website into a new directory then you have to access your website like this http://yourdomain.com/subfolder if you are interested to make a varriable for your root path then you can do it with constant for example `

<?php
define("SITE_URL", "http://yourdomain.com");
?>

`

i apologise for my lack of clarification earlier. here is my exact problem:

basically, i have this script which retrieves files and information from various php files in the /public_html/about folder. the script works fine when placed in a file in /public_html/ (the top level of the domain). however, when i move this script to another fold like /public_html/products it stops working.

i know that the issue is that the path i have set is relative (/public_html/ picks it up because it only has to go to /public_html/about to find it.

the issue is with this line (and there are no other problems with the code):

 define('JPATH_BASE', dirname(realpath(__FILE__)). '/about' );

the only way that these files can be retrieved is to alter the code above slightly, so that it uses an absolute path (which can then be used in any folder).

in essence this is my entire coding:

<?php

// Set flag that this is a parent file

define( '_JEXEC', 1 );

define('JPATH_BASE', dirname(realpath(__FILE__)). '/about' );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.application.module.helper');
jimport('joomla.application.component.helper');

$mainframe =& JFactory::getApplication('site');

if (!$mainframe->getCfg('offline'))
        {
    echo "Online.";
    }
?>

That is the actual local path on the server, so it should most likely be

define('JPATH_BASE', dirname(realpath(__FILE__)). '\\about' );

it's okay, i've solved it.

define('JPATH_BASE', dirname(realpath(__FILE__)). '/../about' );

Hmm. Wonder if this works differently on different OS. I will have to test it.

Meh, ignore me. I am using a windows server...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.