简体   繁体   中英

PHP : file_put_contents failed on directory that created by mkdir

(we use vps on centos linux, but working on subdomain)

Here is my problem:

On localhost in windows, it is just fine, but on intenet in linux, Why the file_put_contents doesn't work in directory that is created by mkdir ?

mkdir('suck', 0664, false);

file_put_contents('suck/stuck.php', 'the stick stack is stuck');

(The error is: failed to open stream: Permission denied in..)

The execution bit needs to be turned on in a folder to be able to manipulate it's contents by the affected user. See Why do directories need the executable (X) permission to be opened?

Directories should be executable by those you want to open them. Executable bit is the lowest order bit. Try this:

mkdir('suck', 0755, false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM