使用 PHP 在 Windows 中设置文件权限
我有一个脚本可以上传 *.csv 以导入到我拥有的数据库表中,该表通过 chmod($target, 0777);
但我不能我的生活找到了解决方案来做到这一点,但在基于 Windows 的 Apache 服务器上.
I have a script that uploads a *.csv to import into a DB table that I have which works great in linux through chmod($target, 0777);
but I can't for the life of me find the solution to do exactly this but on a Windows based Apache server.
其他一些帖子有人回应不要放入 0777,它应该可以工作",但对我来说情况并非如此.谢谢!
Some other posts have people responding "don't put in the 0777 and it should work" but that's not the case for me. Thanks!
推荐答案
感谢在我原来的帖子上留下的评论,我能够在 http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/
Thanks to the comment left on my original post I was able to figure it out with a little more help from http://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/
该问题仅在您使用 PHP 上传文件时发生.当您上传文件时,PHP 会将文件发送到硬盘驱动器(对我来说是 C:WindowsTemp),然后将其复制到它是预期的目录.一旦文件进入临时目录,它被分配了该目录的权限.这问题是当 Windows 复制该文件时,它会保留临时文件目录的权限,并且不会继承您的 Web 目录的权限权限.
The problem only happens when you use PHP to upload a file. When you upload a file, PHP sends the file to a temporary directory on the hard drive (for me it is C:WindowsTemp) and then copies it over to it’s intended directory. Once the file has landed in the temporary directory, it is assigned the permissions of that directory. The problem is when Windows copies that file, it keeps the temporary directory’s permissions and doesn’t inherit your web directory’s permissions.
解决此问题的最简单方法是将您想要的 Web 目录的权限添加到临时目录中.没有必要要删除临时目录中已有的权限,只需添加Web 目录对它们的权限.换句话说,遵循这些步骤
The easiest way to fix this problem is to add to the temporary directory your intended web directory’s permissions. There’s no need to erase the permissions already in the temporary directory, just add the web directory’s permissions to them. In other words, follow these steps
- 要更改临时上传目录的权限,请找到php.ini 文件中的upload_tmp_dir".
- 设置为目录您选择的(当然在您的网络文件夹之外)或将其保留在默认(对我来说是 C:WindowsTemp).
- 浏览到此文件夹并将您的网络文件夹的权限添加到其中.
相关文章