Determining if a File or Directory is a Writable


You want to check if your application has write access.

Specifically, you want to check write access on a file or directory.


Use the File::isWritable() method.

if (File::isWritable($filename))
    echo "Yes. $filename is writable.";
if (File::isWritable($dirname))
    echo "Yes. $dirname is writable.";

If the file or directory exists and is writable true is returned. Otherwise false is returned.


This is a simple wrapper on the PHP is_writable() function.

comments powered by Disqus