Welcome to WebmasterWorld Guest from 54.163.35.238

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

User rights, when making files with php....

and trying to delete them via my ftp account

     

foy

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

10+ Year Member



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?

httpwebwitch

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

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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().

foy

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

10+ Year Member



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...

m_shroom

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

10+ Year Member



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]

coopster

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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);
}

foy

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

10+ Year Member



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?

coopster

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Did you test it?

foy

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

10+ Year Member



yes,

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

fopen()
fwrite()
copy
rename

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.

coopster

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



chmod them after those functions. It should work.

jatar_k

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



or just use a clean up script using unlink
 

Featured Threads

Hot Threads This Week

Hot Threads This Month