2

我正在尝试授予对 php 上传器的访问权限,以将上传的文件写入 apache 范围之外的文件夹。

  • 本例中的文件夹c代表 Windows Server 2012 的根目录

阿帕奇文件夹:

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

php文件夹:

/cygdrive/c/php

上传者文件夹:

/cygdrive/c/apache24/htdocs/uploader

上传者指令:

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

上传者会将文件上传到上传者的文件夹,但我正在尝试将文件上传到 WindowsUsers文件夹。

/cygdrive/c/Users/myusername

如何Users在 php.ini 中启用文件夹和子树,以便上传者可以向其中写入文件?

4

1 回答 1

4

In a *Nix environment you would have to make the target directory writable by the apache process owner. If you don't know what that is, take a look in the httpd.conf file. Look for two lines like:

User _www Group _www

That user must have write access to any target directory. I guess it's just the same in 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.

于 2013-01-26T16:28:31.627 回答