在Windows中使用PHP设置文件权限 [英] Setting File Permissions in Windows with PHP

查看:945
本文介绍了在Windows中使用PHP设置文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,该脚本上载一个* .csv以导入到一个我拥有的数据库表中,该表通过chmod($target, 0777);在linux中运行良好,但是我一生都找不到解决方案来做到这一点,但是基于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!

推荐答案

多亏了我的原始帖子中留下的评论,我得以在

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:\ Windows \ Temp),然后将其复制到 它是预期的目录.一旦文件降落到临时文件中 目录,它被分配了该目录的权限.这 问题是Windows复制该文件时,它会保留临时文件 目录的权限,并且不会继承您的网络目录的 权限.

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:\Windows\Temp) 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目录的权限添加到临时目录中.不用了 要删除临时目录中已有的权限,只需添加 网络目录对其的权限.换句话说,请遵循这些 步骤

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

  1. 要更改您的临时上传目录的权限,请找到 php.ini文件中的"upload_tmp_dir".
  2. 将其设置到目录 您所选择的(当然是在您的网络文件夹之外)或将其保留在 默认(对我来说是C:\ Windows \ Temp).
  3. 浏览到此文件夹,然后向其中添加您的Web文件夹的权限.
  1. To change the permissions of your temporary upload directory, find the "upload_tmp_dir" in your php.ini file.
  2. Set it to the directory of your choosing (outside your web folders of course) or leave it at default (for me it is C:\Windows\Temp).
  3. Browse to this folder and add the permissions of your web folders to it.

这篇关于在Windows中使用PHP设置文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆