简体   繁体   English

在Windows中启用PHP访问文件夹的权限

[英]Enable PHP access to folder in windows

I'm trying to give access to a php uploader to write uploaded files to folders outside of apache's scope. 我试图授予对php上传器的访问权限,以将上传的文件写入apache范围之外的文件夹。

  • Folder c in this case represents the root of Windows Server 2012 在这种情况下,文件夹c表示Windows Server 2012的根目录

The apache folder: apache文件夹:

/cygdrive/c/apache24  (c:\apache24)

The php folder: php文件夹:

/cygdrive/c/php

The uploader folder: 上传器文件夹:

/cygdrive/c/apache24/htdocs/uploader

Uploader directive: 上传器指令:

define('RELATIVE_UPLOAD_DIR', '/cygdrive/c/Users/myusername');
define('UPLOAD_DIR', rtrim(dirname($_SERVER['SCRIPT_FILENAME']), '/') . '/' . RELATIVE_UPLOAD_DIR);

The uploader will upload files to the uploader's folder, but i am trying to upload files to Windows Users folder. 上载器会将文件上载到上载器的文件夹,但是我正在尝试将文件上载到Windows Users文件夹。

/cygdrive/c/Users/myusername

How can i enable the Users folder and subtree in php.ini so the uploader can write files to it? 如何在php.ini中启用“ Users文件夹和子树,以便上传器可以向其中写入文件?

In a *Nix environment you would have to make the target directory writable by the apache process owner. 在* Nix环境中,您必须使目标目录可由apache进程所有者可写。 If you don't know what that is, take a look in the httpd.conf file. 如果您不知道这是什么,请查看httpd.conf文件。 Look for two lines like: 查找类似以下两行:

User _www Group _www 用户_www组_www

That user must have write access to any target directory. 该用户必须具有对任何目标目录的写访问权。 I guess it's just the same in Windows. 我猜在Windows中也一样。

I must admit to not liking the idea of writing to user directories though. 我必须承认不喜欢写用户目录的想法。 Might be better to have a rethink on what you are trying to do and find a way to keep userland safe and secure, whilst giving them access to the data. 最好重新考虑您要尝试做的事情,并找到一种方法来保持用户土地的安全和保障,同时让他们访问数据。

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

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