SitePoint Sponsor |
|
User Tag List
Results 1 to 16 of 16
-
Mar 15, 2006, 12:58 #1
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Delete Directory Using PHP FTP Functions?
Hello,
I'm trying to delete a directory.
I've tried rmdir, but that doesn't work because of a permissions problem (even when I have the permissions at 777.)
So I'm trying to use the FTP functions. I've got them working for everything else, but I don't seem to be able to get them to delete a directory.
I've tried:
ftp_delete($conn_id, 'directory');
But it doesn't work, regardless of whether there is anything in the directory or not.
Any ideas?
Thanks.
-
Mar 15, 2006, 13:14 #2
- Join Date
- Oct 2005
- Location
- South Wales, UK
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
When you use rmdir, what errors do you get? What code do you use?
OMFG SitePoint ROXORZ TEH BIG ONE111!
Wish you were invisible?
-
Mar 15, 2006, 13:25 #3
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:
rmdir('emptydir');
Error:
Warning: rmdir(emptydir) [function.rmdir]: Permission denied in /home/affiliat/public_html/test.php on line 12
Permissions:
0777
-
Mar 15, 2006, 13:39 #4
- Join Date
- Oct 2005
- Location
- South Wales, UK
- Posts
- 1,134
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you want to just remove the file "test.php", you don't need rmdir. Try this:
PHP Code:unlink("test.php");
OMFG SitePoint ROXORZ TEH BIG ONE111!
Wish you were invisible?
-
Mar 15, 2006, 13:43 #5
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No, test.php is the file that is being run. 'emptydir' is the directory that it's trying to delete. Both of which are placed in the public_html directory.
-
Mar 15, 2006, 13:51 #6
is php in safe mode?
-
Mar 15, 2006, 14:07 #7
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No idea. How do I check?
-
Mar 15, 2006, 14:10 #8
phpinfo()
-
Mar 15, 2006, 14:20 #9
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks, but safe mode is off.
Any other ideas?
-
Mar 15, 2006, 14:30 #10
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if the script is running on a different server than the directory is located on, your gonna need to use ftp_rmdir()
-
Mar 15, 2006, 14:32 #11
another thing to check::i believe that it's not only the permissions of the directory you're trying to delete that you have to worry about, but all the dirs above that one. so this particular directory might be 0777, but if a ../../../ directory is read only, you won't be able to delete.
-
Mar 15, 2006, 14:37 #12
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's on the same server. They're located at:
public_html/test.php (this does the deleting)
public_html/emptydir (to be deleted, has nothing in it)
And the permissions are all 777.
So it doesn't quite make sense.
But I'll try ftp_rmdir anyway and see if that works.
-
Mar 15, 2006, 14:45 #13
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
whats the permissons of public_html/ ?
-
Mar 15, 2006, 14:52 #14
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
public_html is at 0755.
-
Mar 15, 2006, 14:57 #15
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
think you need write access to delete something within a directory.
emptydir is in the public_html directory
-
Mar 15, 2006, 15:59 #16
- Join Date
- Mar 2006
- Posts
- 13
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ah-ha! That fixed it.
Thanks a lot!
Bookmarks