开发者

Incoming email to PHP: need to write attachments to web directory

I have a PHP script that is accepting all emails (wildcard) to my domain, and inserting the data into MySQL.

The beginning of the script has this line:

#!/us开发者_如何学Pythonr/bin/php -q

It then looks like a regular PHP script. The part that writes the attachments to disk seems to work but the permissions on the new folders where they're stored were created by the 'nobody' user.

How can I edit permissions so that after these files are written to disk, they can be accessed by the webserver/webserver user?

Thanks for the help!

(Fedora 14 Linux server, Postfix)


You can preform your file system operations by FTP so you will have the same permissions as your user. its better then give all the PHP users on server access to your files. http://php.net/ftp


What user is PHP running as? PHP does have a chmod function, but you can't elevate privileges higher than what the user PHP is running as.

If that doesn't do the trick, could you chown the attachment directory to be owned by whatever user PHP is running as?


I suggest you do the following:

chown -R apache:apache directory_name

This is because PHP runs as the web server user (I believe this is apache on Fedora). Otherwise, if you are using a different web server, then change the ownership of the files to that web server's user (you are sure to find this in the server's configuration files somewhere).


You need sticky bits on the file server level.

setting the sui/sgid bits

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜