Hello.
Please advice.
I have an upload script that should upload an image on a server.
The problem is that it returns the following error:
chmod() [function.chmod]: Not owner in /w...............
I use CHMOD($folder, 0777)
This application runs without a problem on many other servers, except on this one.
safe_mode is off, so CHMOD is not disabled by safe_mode
Thankyou for your help
CHMOD problem
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: CHMOD problem
If the webserver user doesn't own the directory then chmod won't work. You need to chmod it from the command line as the owner, or as the owner chown it to the webserver user.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- Think Pink
- Forum Contributor
- Posts: 106
- Joined: Mon Aug 02, 2004 3:29 pm
Re: CHMOD problem
Yes, I know that CHMOD it won't work.
How can I CHOWN it? I mean how do I find the webserver user?
How can I CHOWN it? I mean how do I find the webserver user?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: CHMOD problem
Depends on your os and web server. I have Apache 2.2 on Ubuntu:Think Pink wrote:Yes, I know that CHMOD it won't work.
How can I CHOWN it? I mean how do I find the webserver user?
Code: Select all
shawn@shawn-laptop:~$ ps -ef|grep apacheCode: Select all
root 4047 16879 0 Jan24 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4053 16879 0 Jan24 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4054 16879 0 Jan24 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4055 16879 0 Jan24 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4056 16879 0 Jan24 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 4057 16879 0 Jan24 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 8795 16879 0 Jan26 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 8798 16879 0 Jan26 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 8802 16879 0 Jan26 ? 00:00:00 /usr/sbin/apache2 -k start
root 16879 1 0 Jan23 ? 00:00:04 /usr/sbin/apache2 -k startmysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- Think Pink
- Forum Contributor
- Posts: 106
- Joined: Mon Aug 02, 2004 3:29 pm
Re: CHMOD problem
Thx for your reply.
So the idea is to create some more test files.
Any ideea if this might work? because I am sick of always sending them a file, upload it, then run some tests, then the feedback back to me.
Sorry, but I know that. The problem is that I don't have access on the server. So I can't run commands. I mean, I develop, and then I send the files to someone else and he uploads. I keep telling them that would be much easier if I would have access or know the settings, or ...or ...or, but is not possible. Looks like they have paranoic settings.You'll need to be root or the owner of the directory in order to chown it.
So the idea is to create some more test files.
Code: Select all
// File name and username to use
$file_name= "winter.txt";
$paths = "/home/xxxx/public_html/yyy/zzz/" . $file_name ;
// Check the result
$stat = stat($paths);
$array = posix_getpwuid($stat['uid']);
$uid = $array['uid'];
// Set the user
chown($paths, intval($uid));
chmod ($paths, octdec($mode));- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: CHMOD problem
No, because the web server user is not root and not the owner of that dir or it would already be able to write to it. Have the admin chmod or chown it or you're out of luck.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.