简体   繁体   English

通过PHP创建目录和文件以及权限问题

[英]Creating Directories and Files through PHP and Permissions Issues

I have a php application that creates directories and files from user input. 我有一个php应用程序,可从用户输入创建目录和文件。 Is it a problem to have php create the directories/files and then use the php chmod function to set the permissions to 755/644? 用php创建目录/文件然后使用php chmod函数将权限设置为755/644是否有问题?

When I do that, it looks like the only way to delete those files is through php. 当我这样做时,似乎删除这些文件的唯一方法是通过php。 So if I want to delete them via FTP, it won't work because apache/php owns them. 因此,如果我想通过FTP删除它们,将无法使用,因为apache / php拥有它们。

Mainly, though I'm trying to figure out if I would need to do anything else besides chmod to 755/644 for the directories/files to make things as secure as possible. 主要是,尽管我试图弄清楚是否除了chmod到755/644以外,还需要对目录/文件进行其他操作以使内容尽可能安全。

Just chmod them to 777 via php. 只需将其通过php chmod更改为777。 Then youll able to delete files from ftp. 然后,您将能够从ftp删除文件。 755 still allows writing only for php.. 755仍然只允许为php编写。

If you use php to create directories and files from user input you should consider disallowing execution of php (and other) scripts from location where it stored. 如果使用php从用户输入中创建目录和文件,则应考虑禁止从其存储位置执行php(及其他)脚本。 This can be done in .htaccess if you are using apache web-server. 如果您使用的是Apache Web服务器,则可以在.htaccess中完成。

AddType text/html .php .cgi .pl .fcgi .fpl .phtml .shtml .php2 .php3 .php4 .php5 .asp .jsp AddType文本/ html .php .cgi .pl .fcgi .fpl .phtml .shtml .php2 .php3 .php4 .php5 .asp .jsp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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