开发者

How can I tell if file is writable from script?

My plugin needs to be able to write to the file system. Is it possible to query a known file for write permissions?

For example, my wordpress theme ships with a fil开发者_StackOverflowe called custom.css that i need write access to. When my theme first loads, I'd like to query this script to see if its writable, then echo the results to my theme.

Then in support session's, I can ask the user to visually check this setting to insure I have write permissions as expected (and eliminate that as the cause of a read/write issue).


is_writable("yourfilename.txt")

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

For example...

if (is_writable('custom.css')) {
    echo "Success!  custom.css is writable";
} else {
    echo "Failure!! custom.css is not writable";
}


I'm probably way too late for this but there is "is_writable"

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜