hi everyone
i have a script that upload a file to the server and i am running apache2
so the default apache usersis www-data and group www-data,so as i upload the
file i want each and every file that uploaded to the server to change from www-data
to staff user name.i keep on getting the following error Warning: chown() [function.chown]: Operation not permitted in /www/upl/file/uploader.php on line 106

please someone can help me to resolve this problem,basically i don't want to change httpd.conf cause i am running multiple site on the server.
i am looking for someone who solved or help me to change the ownership
of the uploaded file.

thanks

It looks like the user (you) doesn't have permissions to run chown on that server

I have the permission to run chown using the command prompt,
so the script that uploading file need to be root before executing
chown.

I have the permission to run chown using the command prompt,
so the script that uploading file need to be root before executing
chown.

How do you chmod these files? Are you doing it yourself or do you have a php script that does chmod after the upload automatically?

If it's your php script that doing the chmod, then it means your apache user account does not own the folder where you trying to do the chmod

I have the permission to run chown using the command prompt,
so the script that uploading file need to be root before executing
chown.

You could do this by writing the file with a process owned by the actual user you want to be the owner.

For example, with FTP. That way you don't need to chown() it afterwards, which requires root privileges.

So after the file is uploaded, instead of writing it to the permanent location using the PHP process, open an FTP connection from PHP to your localhost. Authenticate as the staff user you want. Then write the file with: fput()
http://www.php.net/manual/en/function.ftp-fput.php

That way the ftp process will write the file under the authenticated ftp user uid/gid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.