nirajkumar
nirajkumar

Reputation: 330

PHP and Apache file_exists not working from URL

The below code works (print "file found" ) find if I run it from command line

php a.php

But if I try to access it from browser http://localhost/a.php It prints "file not found".

Its really weird the same URL works fine on the different machine. I am clueless why it is not working.

I have already checked open_basedir it is already disabled and there is no entry in the httpd.conf

 if(file_exists("/mnt/disk1/a.jpg"))
{ 
  echo "file found";
}     else
{ 
  echo "file not found";    }   ?>

Upvotes: 1

Views: 842

Answers (1)

Jeff Puckett
Jeff Puckett

Reputation: 40861

The web server user account must have permission to read the file - this is a different user account than the one you use on console.

sudo chmod +rx /mnt/disk1/a.jpg

Apache also needs execute access on all folders to root.

sudo chmod +x /mnt/disk1
sudo chmod +x /mnt

Upvotes: 2

Related Questions