PHP Unlink function Woes on Windows
Posted
by Abs
on Stack Overflow
See other posts from Stack Overflow
or by Abs
Published on 2010-06-11T12:35:34Z
Indexed on
2010/06/11
12:43 UTC
Read the original article
Hit count: 507
Hello all,
I am having problems with the PHP function unlink. I keep getting this error:
Warning: unlink(C:\wamp\www\webs\db\db_1276259188.mdb) [function.unlink]: Permission denied in C:\wamp\www\webs\pure-php-export.php on line 242
I am on a windows machine where Apache runs as the user SYSTEM. I have set the permissions of the db folder as "Full Control" for Apache's user.
I thought my script might still be holding on to that file (its an uploaded file that gets used via PDO).
try{
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $username, $password);
}catch(PDOException $e){
echo $e->getMessage();
}
So before I attempt to delete the file I unset the above and try to delete like so:
$dbh = null;
unset($dbh);
if(is_file($mdbFilename)){
unlink($mdbFilename);
}
I really appreciate any help on this as it has been driving me mental for the past two hours!
Thanks all for any help.
© Stack Overflow or respective owner