Max Frai
Max Frai

Reputation: 64266

PHP directory location

I can't understand how to save directory location.

The script is located in some subfolder of root one. Here is the example tree:

|-index.php
|-another.php
|+empty_folder
|+subfolder
|---script.php

I'm running from script.php. I have to save in database path for the empty_folder. In script I use the code:

if (is_writable($PATH)) ...

And it returns error every time (can't open the folder). Now $PATH looks like ../empty_folder and this doesn't work.

Any ways?

Upvotes: 0

Views: 312

Answers (2)

ChrisH
ChrisH

Reputation: 1281

Instead of ../ try the use of the full path: if(is_writeable('/srv/http/wordpress/'))

Upvotes: 2

Marc B
Marc B

Reputation: 360602

is_writable only returns false if the specified path cannot be written to by the current user ID. That can be because the path doesn't exist, or the current user ID doesn't have the writes to write there.

What are the permissions on empty_folder (user/group + permissions) and what userID/groupID is your script running under (web server's?).

Upvotes: 1

Related Questions