Vote Up 0 Vote Down

php is _writable windows bug

What is php is _writable windows bug
flag

Answers


Vote Up 0 Vote Down
<?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
flag | link |

Your Answer

Login before answering

Login with facebook