Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 388
Kin Avatar asked Nov 29 '22 05:11

Kin


2 Answers

$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."

like image 184
Select0r Avatar answered Dec 06 '22 04:12

Select0r


fileperms gets permissions for the given file.

like image 26
murze Avatar answered Dec 06 '22 02:12

murze