note 68098 added to function.is-writable

From: Date: Thu, 13 Jul 2006 08:17:07 +0000
Subject: note 68098 added to function.is-writable
Groups: php.notes 
Request: Send a blank email to php-notes+get-114725@lists.php.net to get a copy of this message
Since looks like the Windows ACLs bug "wont fix" (see http://bugs.php.net/bug.php?id=27609) I propose this alternative function: <?php function is__writable($path) { if ($path{strlen($path)-1}=='/') return is__writable($path.uniqid(mt_rand()).'.tmp'); if (file_exists($path)) { if (!($f = @fopen($path, 'r+'))) return false; fclose($f); return true; } if (!($f = @fopen($path, 'w'))) return false; fclose($f); unlink($path); return true; } ?> It should work both on *nix and Windows NOTE: you must use a trailing slash to identify a directory ---- Server IP: 213.92.11.19 Probable Submitter: 151.44.95.154 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.is-writable.php Edit -- http://master.php.net/note/edit/68098 Del: integrated -- http://master.php.net/note/delete/68098/integrated Del: useless -- http://master.php.net/note/delete/68098/useless Del: bad code -- http://master.php.net/note/delete/68098/bad+code Del: spam -- http://master.php.net/note/delete/68098/spam Del: non-english -- http://master.php.net/note/delete/68098/non-english Del: in docs -- http://master.php.net/note/delete/68098/in+docs Del: other reasons-- http://master.php.net/note/delete/68098 Reject -- http://master.php.net/note/reject/68098 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114725) next »