homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

User rights, when making files with php....
and trying to delete them via my ftp account

 3:41 pm on Jul 8, 2004 (gmt 0)

okay... so here I go...

I'm running a php script on my apache2 which is actually generating files on the server.

So I want to delete these files again via my ftp client but it says "permission denied" thouth the ftp user has full rights to the folder (let's call it "test) the files are being generated in.

When I look at the file that has to be deleted it says that it's owned by user "nobody" and group "4294967295", while my ftp user is called "wwwftp" and its group is "ftpusers", so I can't delete with wwwftp what "nobody" created.

How can I setup my ftp user "wwwftp" that it has complete rights under the folder "test"? No matter which user creates files?



 3:52 pm on Jul 8, 2004 (gmt 0)

I hear your plight. Had the same crisis earlier this year. On my server, the PHP ghost was named "localhost", and I was "httpwebwitch", and neither could do anything with files from the other. If a file was created with PHP, it had to be deleted with PHP. If it was created/sent via FTP, it had to be deleted via FTP. Isn't it annoying?

Back when I was having the problem, I tried a few experiments with PHP "chmod" and setting permissions from FTP, nothing worked.

But be thankful it works like that. It's a security thing. It's Good.

a couple of options:

1) Get the server administrator (a.k.a. superuser) to delete the files for you.

2) do just as I mention above - use PHP to delete the files. Make yourself a little script that uses unlink().


 4:15 pm on Jul 8, 2004 (gmt 0)

thanks for your sympathy =)

I'm the admin myself, running SUSE Linux 9.1 with Apache2 and PHP with Zend.

Maybe this is an issue with safe_mode? though is safe_mode is off in my php.ini...


 4:41 pm on Jul 8, 2004 (gmt 0)

I to had the same problem but solved it.

{mkdir("thumbnails/$row[3]"); chmod("thumbnails/$row[3]",0777);}

Let php make it , let php chomd.

[edited by: m_shroom at 4:42 pm (utc) on July 8, 2004]


 4:42 pm on Jul 8, 2004 (gmt 0)

After you move_uploaded_file(), chmod the file to 0644.
$uploaddir = '/var/www/uploads/'; 
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
@chmod($uploadfile, 0644);


 4:45 pm on Jul 8, 2004 (gmt 0)

I want to have the file(s) chmod 0644 but still deletable with user "wwwftp" of the group "ftpusers".

So in other words it's not possible unless I chmod the files to 0777?


 4:46 pm on Jul 8, 2004 (gmt 0)

Did you test it?


 4:53 pm on Jul 8, 2004 (gmt 0)


but my problem is that i use these functions in php:


after that, I can't delete them via ftp.

when I use move_uploaded_file() it works but that's not the thing I wanted to achieve since I write files with fwrite on the server itself and do not particularly upload them from a remote location.


 5:11 pm on Jul 8, 2004 (gmt 0)

chmod them after those functions. It should work.


 9:19 pm on Jul 8, 2004 (gmt 0)

or just use a clean up script using unlink

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved