开发者

How do I configure PHP to have permission to create directories and make files?

I have a PHP script that receives uploads and it works fine in mamp, creating directories and receiving files as necessary, but when I move it to the server it errors out saying it开发者_运维技巧 can't do either.

[EDIT] To be clear, the script will received a file and before storing it, it may need to create a directory for that file beneath itself. So the pseudo code would be...

$path = getNewPath();
mkdir("./$path", RECURSIVE);
fwrite($path/$newFile);

I've chowned the file to apache and given it 777 permissions, but no dice. I'm assuming that there must be some PHP configuration that designates this, but can't figure out where that is. httpd.conf is lengthy and, having skimmed it, I don't see anything relevant.

I'm sure I'm missing something obvious, but can't figure out what it is.

TIA


The script must be able to write to the parent directory in order to create sub directories, so chmod 777 the parent directory, for instance httpdocs/uploads/ or wherever you are storing these files.


chown or chmod 777 the directories where the script wants to write (create) the files and NOT the script itself.


chmod("/somedir/somefile", 0777);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜