2

I have written small CMS in Laravel 4 and I was working on it using wamp. Application was in www folder and everything was working fine. When I have finished with development, I moved an application to my live server and I have put application in root folder of my hosting (folder above public_html). In some functions I'm checking if some files exist, and while I was on wamp, everything worked, but now file_exists() always returns false. Folder permissions of the folder where files are stored are set to 755, and files are with same permissions.

I have already tried clearstatcache() and Safe mode cannot be an issue since it was removed in PHP 5.4. Any other ideas?

if(file_exists('public_html/repo/images/testimage.jpg')){
    //do something
}
else{
    echo "error";
}

I have checked several times, and file does exists if I try to access it via url

3
  • Turn off safe mode using safe_mode_include_dir? Also, ls -l /home/user/public_html/root/ and add the output to your question. Commented Jul 18, 2013 at 20:40
  • I'd bet that the path to the files is different, and you're either using a leading / when you shouldn't be, or you've omitted it when you shouldn't. Can you post some code please? Commented Jul 18, 2013 at 20:41
  • safe_mode_include_dir is already at no value. I thought it was php 5.4 and it is 5.3.26. Safe mode is off. Also I have added sample code above Commented Jul 18, 2013 at 20:49

1 Answer 1

4

Well, first you said you were in WAMP, it could be that folders were having uppercases. Remember, windows is not case-sensitive for folder while linux is.

Second, where's laravel's index.php file? (It's generaly in public folder), file_exists() is relative to it, so if your installation is: public_html/public/index.php and repo/images is on public folder you should check for: file_exists('repo/images...');

Laravel is designed to keep its files outside of public access, so I suggest you put laravel's files and folders in the root / while moving everything in public folder to public_html. This way, you could check file existence relatively to public_html folder.

file_exists('repo/images...');
file_exists('../app/views/hello.blade.php');
...
Sign up to request clarification or add additional context in comments.

2 Comments

Everything is in the root and basically my public folder is public_html
so don't include 'public_html' in the path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.