note 115437 added to function.is-writable
| From: | samuel dot zallocco at univaq dot it | Date: | Wed, 23 Jul 2014 12:57:10 +0000 |
| Subject: | note 115437 added to function.is-writable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200039@lists.php.net to get a copy of this message | ||
Check if a directory is writable. Work also on mounted SMB shares:
function isWritablePath($home, $xpath) {
$isOK = false;
$path = trim($xpath);
if ( ($path!="") && (strpos($path,$home)!==false) && is_dir($path)
&& is_writable($path) ) {
$tmpfile = "mPC_".uniqid(mt_rand()).'.writable';
$fullpathname = str_replace('//','/',$path."/".$tmpfile);
$fp = @fopen($fullpathname,"w");
if ($fp !== false) {
$isOK = true;
}
@fclose($fp);
@unlink($fullpathname);
}
return $isOK;
}
----
Server IP: 72.52.91.14
Probable Submitter: 192.150.195.23
----
Manual Page -- http://php.net/manual/en/function.is-writable.php
Edit -- https://master.php.net/note/edit/115437
Del: integrated -- https://master.php.net/note/delete/115437/integrated
Del: useless -- https://master.php.net/note/delete/115437/useless
Del: bad code -- https://master.php.net/note/delete/115437/bad+code
Del: spam -- https://master.php.net/note/delete/115437/spam
Del: non-english -- https://master.php.net/note/delete/115437/non-english
Del: in docs -- https://master.php.net/note/delete/115437/in+docs
Del: other reasons-- https://master.php.net/note/delete/115437
Reject -- https://master.php.net/note/reject/115437
Search -- https://master.php.net/manage/user-notes.php