开发者

How to create directories in PHP that can actually be used (mkdir() and apache problem)?

开发者 https://www.devze.com 2023-03-21 06:27 出处:网络
I have literally spent days searching for a solution to this problem. PHP\'s mkdir() function is creating directories with owner/group: apache:apache. There is no way I can work in this directory via

I have literally spent days searching for a solution to this problem. PHP's mkdir() function is creating directories with owner/group: apache:apache. There is no way I can work in this directory via FTP because the file doesn't belong to me.

How in the world am I supposed to create directories and manage files with PHP if the user is always set to apache?

Is there a workaround? Should I create directories via exec() or system() ?

A开发者_如何转开发ny help is appreciated.

tundoopani


Solving cross-user access problems between a PHP installation and another sub-system (in this case, FTP) usually involves one of two solutions: running both sub-systems as the same user, or putting both users in a common group.

In any case, the FTP protocol lets you create directories. Why not create them from your FTP client?


You can chown() them ( Changes file owner)

however note that

Only the superuser may change the owner of a file.


You could use PHP's:

chown(string $filename, mixed $user);

You can just pass in a director instead of a file as $filename, and your username into $user.

0

精彩评论

暂无评论...
验证码 换一张
取 消