I'm running PHP 5.2.6 on a Windows Server 2003 Enterprise box. IIS is set to deny anonymous access and use Integrated Windows authentication.
我在Windows Server 2003 Enterprise框上运行PHP 5.2.6。 IIS设置为拒绝匿名访问并使用集成Windows身份验证。
I'm using a PHP script to save a file uploaded from a web form. The file is uploaded to a temp folder, the script creates a file name and path depending on other variables from the web form, and then the script uses PHP's move_uploaded_file() to move the temp file to the final location. All that works fine. In short, people are uploading files so everyone in the group can see them and the files are organized by the script.
我正在使用PHP脚本来保存从Web表单上传的文件。文件上传到临时文件夹,脚本根据Web表单中的其他变量创建文件名和路径,然后脚本使用PHP的move_uploaded_file()将临时文件移动到最终位置。一切正常。简而言之,人们正在上传文件,以便组中的每个人都可以看到它们,并且文件由脚本组织。
My problem is that the file in the final location has odd permissions. It is not ending up with permissions from either the temp location or the final location. Both the temp location and final location have the same permissions: full rights for owner and administrations; read and read/execute for 2 specific AD security groups. The final file ends up with only: full rights for owner and administrations. So while the admins and the original uploader have no problem viewing the file, all others in the group get "permission denied" when trying to access it.
我的问题是最终位置的文件具有奇怪的权限。它不会以临时位置或最终位置的权限结束。临时位置和最终位置都具有相同的权限:所有者和管理员的完全权限;读取和读取/执行2个特定的AD安全组。最终文件仅以:所有者和管理员的完全权利结束。因此,虽然管理员和原始上传者在查看文件时没有问题,但组中的所有其他人在尝试访问时都会获得“权限被拒绝”。
Any ideas or suggestions will be greatly appreciated! Thanks!
任何想法或建议将不胜感激!谢谢!
2 个解决方案
#1
4
This seems to be an issue with the move_uploaded_file()
function:
http://us3.php.net/move_uploaded_file
Take a look at the comments below, take note of Florian's comment about copy().
Would copy() solve the issue?:
http://us3.php.net/manual/en/function.copy.php
这似乎是move_uploaded_file()函数的一个问题:http://us3.php.net/move_uploaded_file看看下面的评论,注意Florian关于copy()的评论。 copy()会解决问题吗?:http://us3.php.net/manual/en/function.copy.php
#2
7
from the php page on move_uploaded_file (nb: this worked for me):
来自move_uploaded_file上的php页面(nb:这对我有用):
For those using PHP on Windows and IIS, you SHOULD set the "upload_tmp_dir" value in php.ini to some directory around where your websites directory is, create that directory, and then set the same permissions on it that you have set for your websites directory. Otherwise, when you upload a file and it goes into C:\WINDOWS\Temp, then you move it to your website directory, its permissions will NOT be set correctly. This will cause you problems if you then want to manipulate that file with something like ImageMagick's convert utility.
对于那些在Windows和IIS上使用PHP的人,你应该将php.ini中的“upload_tmp_dir”值设置到你的网站目录所在的某个目录,创建该目录,然后为你的网站设置相同的权限。目录。否则,当您上传文件并进入C:\ WINDOWS \ Temp,然后将其移动到您的网站目录,其权限将无法正确设置。如果您想要使用ImageMagick的转换实用程序来操作该文件,这将导致您出现问题。
#1
4
This seems to be an issue with the move_uploaded_file()
function:
http://us3.php.net/move_uploaded_file
Take a look at the comments below, take note of Florian's comment about copy().
Would copy() solve the issue?:
http://us3.php.net/manual/en/function.copy.php
这似乎是move_uploaded_file()函数的一个问题:http://us3.php.net/move_uploaded_file看看下面的评论,注意Florian关于copy()的评论。 copy()会解决问题吗?:http://us3.php.net/manual/en/function.copy.php
#2
7
from the php page on move_uploaded_file (nb: this worked for me):
来自move_uploaded_file上的php页面(nb:这对我有用):
For those using PHP on Windows and IIS, you SHOULD set the "upload_tmp_dir" value in php.ini to some directory around where your websites directory is, create that directory, and then set the same permissions on it that you have set for your websites directory. Otherwise, when you upload a file and it goes into C:\WINDOWS\Temp, then you move it to your website directory, its permissions will NOT be set correctly. This will cause you problems if you then want to manipulate that file with something like ImageMagick's convert utility.
对于那些在Windows和IIS上使用PHP的人,你应该将php.ini中的“upload_tmp_dir”值设置到你的网站目录所在的某个目录,创建该目录,然后为你的网站设置相同的权限。目录。否则,当您上传文件并进入C:\ WINDOWS \ Temp,然后将其移动到您的网站目录,其权限将无法正确设置。如果您想要使用ImageMagick的转换实用程序来操作该文件,这将导致您出现问题。