Last active
August 29, 2015 13:57
-
-
Save jk2K/9636804 to your computer and use it in GitHub Desktop.
测试文件夹是否可写
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dir_writeable($dir) { | |
$writeable = 0; | |
if(!is_dir($dir)) { | |
@mkdir($dir, 0777); | |
} | |
if(is_dir($dir)) { | |
if($fp = @fopen("$dir/test.txt", 'w')) { | |
@fclose($fp); | |
@unlink("$dir/test.txt"); | |
$writeable = 1; | |
} else { | |
$writeable = 0; | |
} | |
} | |
return $writeable; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment