PHP/File Directory/is writable — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
is_writable() tells you whether you can write to a file.
<?
if ( is_writable( "data.txt" ) ) {
print "data.txt is writable";
}
?>
is_writeable
<?php
$file_name="permissions.php";
if(is_writeable($file_name)) {
echo ("The file $file_name is writeable.<br />");
}
else {
echo ("The file $file_name is not writeable.<br />");
}
?>
Testing for write permission
$log_file = "/var/log/users.log";
if (is_writeable($log_file)) {
$fh = fopen($log_file,"ab");
fwrite($fh, $_SESSION["username"] . " at " . strftime("%c") . "\n");
fclose($fh);
} else {
print "Can"t write to log file.";
}