note 69948 deleted from function.is-writable by nlopess

From: Date: Wed, 27 Sep 2006 18:39:24 +0000
Subject: note 69948 deleted from function.is-writable by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117742@lists.php.net to get a copy of this message
Note Submitter: Ilija Studen ---- People using IIS reported serious problems with activeCollab (http://www.activecollab.com/) because of http://bugs.php.net/bug.php?id=27609. Installer said that folders are writable and than they received a bunch of write errors when they tried to upload something. Solution this two simple functions: <?php function folder_is_writable($path) { if(!is_dir($path)) { return false; } do { $test_file = $path . '/' . sha1(uniqid(rand(), true)); } while(is_file($test_file)); $put = @file_put_contents($test_file, 'test'); if($put === false) { return false; } @unlink($test_file); return true; } function file_is_writable($path) { if(!is_file($path)) { return false; } $open = @fopen($path, 'a+'); if($open === false) { return false; } @fclose($open); return true; } ?>

« previous php.notes (#117742) next »