使用 PHP 在没有正确权限的情况下写入文件
我正在尝试为我的 PHP(CodeIgniter) 应用程序创建一个安装脚本,我需要将从用户那里获得的数据库信息写入 CI 数据库配置文件。当然,我这样做遇到了权限问题,因为配置目录没有写权限。所以我的问题是,如果不让安装我的应用程序的用户自己管理文件夹权限,这将如何实现。
I'm trying to create a installation script for my PHP(CodeIgniter) app and i need to write database info that i get from user to CI database conf file. Of course i run into permissions problem doing so because config directory doesn't have write permission. So my question is how would this be possible without making user who installs my app to manage folder permissions him/herself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
他们必须有权访问网络服务器的文件夹读/写选项 - 许多主机不允许您通过 FTP 访问来执行此操作,因此您甚至无法使用它来执行直接解决方案 - 他们可能必须通过控制面板系统可以完成此类任务。
那里没有“运行此脚本,它将更改文件夹权限”代码 - 最终用户必须足够精明才能知道如何执行此操作。
They have to have access to the webserver's folder read/write options on their end - many hosts don't let you do this through FTP access so you can't even do a direct solution using that - they may have to go through the Control Panel system to do this type of task.
There's no "Run this script and it'll change folder permissions" code out there - the end user will have to be savvy enough to know how to do this.
您可以尝试这样的操作:
您可以使用 chmod 更改文件夹/文件权限:
http://php.net/manual/en/function.chmod.php
You could try something like this:
You can use
chmod
to change the folder/file permission:http://php.net/manual/en/function.chmod.php