icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » [PHP] Folder/Files deleting permission problems

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old August 23rd, 2005, 6:43 PM   #1 (permalink)
Registered User
Comfy Contributor
 
Z`ohki's Avatar
 
Joined in Aug 2005
Lives in Netherlands
Hosted on Pass48
124 posts
Gave thanks: 0
Thanked 0 times
[PHP] Folder/Files deleting permission problems

I was messing around with the mkdir(); and copy(); functions of PHP.

Then I created the directories and copied the files into them like it should.
Only they were test dir's, and now I can't delete them anymore.

My FTP client says this :

"550 Could not delete blah.jpg: Permission denied".

I can't remove/rename/move the file anywhere, also not by the Cpanel Filemanager.

When I try to chmod it I get this :
"550 Could not change perms on blah.jpg: Bad file descriptor"

I can't also upload any files anymore in those directories where that file is.
But I can rename the folder the file is in, only not delete it

Anybody an idea to remove them?

I used this in my php file :

PHP Code:
$file 'blah.jpg';
$dir '../test';
$user 'test'

mkdir($dir.'/'.$user);
copy($dir.'/'.$file$dir.'/'.$user.'/'.$file); 
It worked like it should, only wrong permissions appearently, how could I remove the files and prevent this from happening?

Thanks
Z`ohki is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 23rd, 2005, 10:50 PM   #2 (permalink)
Registered User
Comfy Contributor
 
OmicroN's Avatar
 
Joined in May 2003
Lives in Florida
118 posts
Gave thanks: 0
Thanked 0 times
Thumbs up

Hello Z`ohki,

The PHP function mkdir() doesn't create directories under your name but instead by the process running PHP which is usually 'nobody'. Since the directory isn't created under your name you therefore don't have persmission to delete the directory.

To delete the directory use the PHP function rmdir() which is remove directory; since it also uses the PHP process user it'll have permissions to delete the folder. As for alternatives to your solution, you're going to have to use PHP's ftp functions and have it login to your ftp with your username and password and use the ftp mkdir function which is ftp_mkdir().

You can find lots of working examples of scripts already made to do just that by reading the comments on PHP's site for the mkdir() function here http://us2.php.net/mkdir
__________________
Profession: Programmer, Gamer, Web Developer
Website: http://www.reanimated.net/ - Server: Quela

Last edited by OmicroN; August 23rd, 2005 at 10:53 PM..
OmicroN is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 24th, 2005, 3:03 AM   #3 (permalink)
Registered User
Comfy Contributor
 
Z`ohki's Avatar
 
Joined in Aug 2005
Lives in Netherlands
Hosted on Pass48
124 posts
Gave thanks: 0
Thanked 0 times
Thanks I got it now, I had tried with rmdir(); as well before posting, only it said that it wasn't empty all the time. So I tried with 'delete()' but that didn't work.

I saw unlink() at php.net, only I didn't know it was for deleting files as well.
But I just used that and now I can remove them.

Thanks for the help!
Z`ohki is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On