문제

I have the below code running and will give the CHMOD and CHOWN values below. But for some reason is_writable keeps failing.

if (!is_writeable($this->path)) {
  echo 'Current script owner: ' . get_current_user();
  echo '<br />';
  echo $this->path;
  echo '<br />';
  print_r(posix_getpwuid(fileowner($this->path)));
}

The CHMOD values of the directory is 775 and the owner is User1. The output from above is

Current script owner: User1 
path/to/directory  
Array ( [name] => User1 [passwd] => x [uid] => 111 [gid] => 111 [gecos] => [dir] =>
/path/to/user [shell] => /bin/false )

The only thing that doesn't match is the owner / group of the file is 111/1 so the groups might be different but the owner is identical. Why would is_writeable fail?

도움이 되었습니까?

해결책

Are you the owner or the webserver?

Everything you execute with the webserver should run as www, _www or www-data (depending on the configuration; default values for different OS). So the webserver user is not in your group which causes that the file is not writeable by the webserver.

(P.s.: get_current_user() is the script owner (e.g. what you set by chown), not the script running user. Current script running user data: var_dump(posix_getpwuid(posix_getuid()));)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top