this is the code

if (file_exists('/user/'.$_SESSION['Username'].'/avatar.jpg')) {
echo 'Exists';
} else {
    echo 'Doesn\'t exist';
}

and i get the negative case

Are you sure you are referring to the right path? The slash before user directs it to the root of your server. Perhaps it should be ./user/, which finds the user folder in the current directory.

not working

Member Avatar for diafol

Your related thread stated this at the end...

i solve it with dirname(__FILE__)

Which I thought was overkill, as './'by pritaeas pretty much sets the location relative to the current directory.

not working

Please read this forum's read-me and you'll understand why that comment is completely worthless to us.

i'm not sure will work because the code is in a included file through many levels

Member Avatar for diafol

You could always do an absolute...

$dir = $_SERVER['DOCUMENT_ROOT'];
$dir .= '/subdirectory1/subsubdirectory7/';

This assumes that you haven't stored the upload directory above the document root. This is a bit of a fudge though.

Setting constants like UPLOAD_PATH like these in your top include file (e.g. config.php file) can often obviate these types of problems.

i get "open_basedir restriction in effect. File(/usr/local/apache/htdocs/user/name_of _user/avatar.jpg) is not within the allowed path(s)"

i dont have any control over the server

Member Avatar for diafol

You looked at the link?

yes but there it tells me to modify apache configurations and restart it. I cant do that on my host

Member Avatar for diafol

Do you have cPanel WebHost Manager or Plesk?

Where on your website is the actual file stored?

e.g. http: //www.mywebsite.com/assets/images/avatar.jpg

here's the image
www.jocurigratisonlinenet.ro/user/axxxA/avatar.jpg

i don't have cpanel or plesk, i have somekind of control panel

i have somekind of control panel

I think it might be best if you raised a support ticket with your host.

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.