Kin
Kin

Reputation: 1407

How can I determine in PHP if I have write permissions to a folder

I'm writing a WordPress plugin that requires manipulating files in the plugin directory, and I can't figure out how to diagrammatically determine whether PHP has write permissions to a folder. How would I go about achieving this in a relatively simple manner?

Upvotes: 4

Views: 5254

Answers (3)

Select0r
Select0r

Reputation: 12668

$b = is_writable( "/file/or/folder/to/test" ); //boolean value

http://php.net/manual/en/function.is-writable.php

Works on files as well as on folders: "Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable."

Upvotes: 14

Alex Pliutau
Alex Pliutau

Reputation: 21947

Try this function: is_writable()

Upvotes: 4

murze
murze

Reputation: 4103

fileperms gets permissions for the given file.

Upvotes: 4

Related Questions