Hi,
Apparently my safe mode is off. I tried fiddling with my code by changing the
permission of my intended to delete file as in the following:
<?php
ini_set('display_errors', 1); error_reporting(E_ALL);
$curDir = getcwd();
chmod($curDir,0777);
echo substr(sprintf('%o', fileperms($curDir)), -4);
$fileToRemove = "C:/Inetpub/wwwroot/project/testFile.txt";chmod ($fileToRemove,
0777) or die ("permission canonot be set");
echo substr(sprintf('%o', fileperms($fileToRemove)), -4);
if (@unlink($fileToRemove) == true) {
unlink($fileToRemove);
} else {echo "You don't have the permission";}
?>
This is the output I get
07770666You don't have the permission
I don't get a failure statement in the line: chmod ($fileToRemove, 0777) or die
("permission canonot be set");, how come the permission of this file is still
0666?
Thanks in advance.
Alice
> Date: Tue, 13 Jan 2009 17:06:37 +0100> From: li...@bithub.net> To:
> aj...@alumni.iu.edu> CC: php-general@lists.php.net> Subject: Re: [PHP] PHP
> unlink Errors> > Do you have php_safe_mode enabled? If's that's the case, try
> turning it > off and then run your script again.> Alice Wei wrote:> > Hi, > >
> > > I have a snippet below that I would like to delete a file. However, I
> keep getting kicked out because of permission errors, when my folder
> permission is 0777. > > > > <?php> > > > ini_set('display_errors', 1);
> error_reporting(E_ALL);> > $curDir = getcwd();> > chmod($curDir,0777) or die
> ("Failed to change permission");> > echo substr(sprintf('%o',
> fileperms($curDir)), -4); > >
> unlink("C:/Inetpub\wwwroot/project/testFile.txt");> > echo
> unlink("C:/Inetpub/wwwroot/pproject/testFile.txt"); > > > > ?> > > > > Is it
> possible that someone on the list could point out what my possible errors are
> to allow this code to be functioning? > > > > Here is the output:> > > >
> 0777Warning: unlink(C:/Inetpub\wwwroot/project/testFile.txt)
> [function.unlink]: Permission denied in
> C:\Inetpub\wwwroot\project\file_write.php on line 9Warning:
> unlink(C:/Inetpub/wwwroot/project/testFile.txt) [function.unlink]: Permission
> denied in C:\Inetpub\wwwroot\project\file_write.php on line 10> > > > Thanks
> in advance. > > > > Alice> >
> _________________________________________________________________> >
> All-in-one security and maintenance for your PC. Get a free 90-day trial!> >
> http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail> > > -->
> http://bithub.net/> Synchronize, share and backup your files over the web for
> free> > http://twitter.com/MarcSteinert> My Twitter feed> **
_________________________________________________________________
Search from any Web page with powerful protection. Get the FREE Windows Live
Toolbar Today!
http://get.live.com/toolbar/overview