RE: [PHP] PHP unlink Permission Error

From: Date: Tue, 13 Jan 2009 15:14:41 +0000
Subject: RE: [PHP] PHP unlink Permission Error
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-286218@lists.php.net to get a copy of this message
Hi, Ashley: I tried to find your corrected errors, but I cannot seem to find it. Have you sent me an empty reply message by mistake? Alice> Subject: RE: [PHP] PHP unlink Permission Error> From: ash@ashleysheridan.co.uk> To: Alice> ajwei@alumni.iu.edu> CC: php-general@lists.php.net> Date: Tue, 13 Jan 2009 15:09:44 +0000> Alice> > On Tue, 2009-01-13 at 09:50 -0500, Alice Wei wrote:> > Hi, Ashley:> > > > I Alice> thought about it and edited my script to check what permission I> > had, and it appears I do Alice> have the permission rights, and it actually> > changed to 0777. Here is the code:> > Alice> > > <?php> > > > ini_set('display_errors', 1); > > Alice> error_reporting(E_ALL);> > $curDir = getcwd();> > chmod($curDir,0777) or die Alice> ("Failed to change permission");> > echo substr(sprintf('%o', Alice> fileperms($curDir)), -4); > > unlink("testFile.txt");> > echo Alice> unlink("testFile.txt"); > > > > ?> > > > > The output:> > Alice> > > 0777> > Warning: unlink(testFile.txt) [function.unlink]: Permission denied in> Alice> > C:\Inetpub\wwwroot\project\file_write.php on line 10> > > > Warning: Alice> unlink(testFile.txt) [function.unlink]: Permission denied in> > Alice> C:\Inetpub\wwwroot\project\file_write.php n line 11> > > > If this is the case, how come Alice> I don't have the permissions to delete> > the file?> > Thanks again.> > > Alice> > Alice> > > > > > > Subject: Re: [PHP] PHP unlink Permission Error> > Alice> > From: ash@ashleysheridan.co.uk> > > To: ajwei@alumni.iu.edu> > > CC: Alice> php-general@lists.php.net> > > Date: Tue, 13 Jan 2009 14:53:32 +0000> > > > Alice> > > On Tue, 2009-01-13 at 09:42 -0500, Alice Wei wrote:> > > > Hi, > > > Alice> > > > > > I have a snippet of code as follows:> > > > > > > > Alice> <?php> > > > > > > > ini_set('display_errors', 1); Alice> error_reporting(E_ALL);> > > > $curDir = getcwd();> > > > echo $curDir;> Alice> > > > chmod($curDir,0777);> > > > unlink("testFile.txt");> > Alice> > > echo unlink("testFile.txt"); > > > > chmod ($curDir,0755);> > Alice> > > ?> > > > > > > > > The problem is that I do not seem to have Alice> the correct permissions,> > even though I seem to have changed the permissions of the folder Alice> to> > 777 already upon the file deletion time. This is the output I got:> > > > Alice> > > > > C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt)> > Alice> [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project> > \file_write.php on line Alice> 9Warning: unlink(testFile.txt)> > [function.unlink]: Permission denied in Alice> C:\Inetpub\wwwrootproject> > \file_write.php on line 10> > > > > > > > Alice> Could anyone give me some tips on how to resolve this error?> > Thanks in advance.> > Alice> > > > > > > Alice> > > > Alice> _________________________________________________________________> > > > All-in-one Alice> security and maintenance for your PC. Get a free 90-day> > trial!> > > > Alice> http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail> Alice> > > > > > You're using chmod to modify the permissions of the directory, but> Alice> > do> > > you actually have permissions to modify the permissions? If not, the> > Alice> > chmod will fail without giving an error, and then your unlink will> > fail> > > Alice> with an error.> > > > > > > > > Ash> > > Alice> www.ashleysheridan.co.uk> > > > > > > > > > > Alice> ______________________________________________________________________> > Search from any Web Alice> page with powerful protection. Get the FREE> > Windows Live Toolbar Today! Try it now!> Alice> Hmm, is the current working directory the same as the one in which the> file is in? I know it Alice> seems like a silly question, but it's often the> silly ones that cause the most trouble!> Alice> > > Ash> www.ashleysheridan.co.uk> _________________________________________________________________ Use Messenger to talk to your IM friends, even those on Yahoo! http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe

« previous php.general (#286218) next »