问题描述
我正在使用PHP开发CMS作为学习练习,但是遇到了一个名为"open_basedir限制"的难题-我正在尝试上传一个小的JPG文件.我尝试提供尽可能简洁的信息,但是如果我忘了任何信息,请告诉我!
I'm developing a CMS in PHP as a learning exercise but have hit a brickwall called "open_basedir restriction" - I am trying to upload a small JPG file. I've tried to give as much info as concisely as possible but let me know if I forgot anything!
我可以看到它每次都击中c:/windows/temp/文件夹,因此它只有在尝试执行 move_uploaded_file 操作时才会掉落.
I can see it hit the c:/windows/temp/ folder every time so its only falling over when trying to perform the move_uploaded_file operation.
经过大量研究,我知道这是什么,并且从理论上讲,如何在线阅读许多页面后如何解决该问题:
After much research I know what this is and in theory how to fix it having read a number of pages online such as:
http://forum.parallels. com/showthread.php?258036-Plesk-Windows-open_basedir-restriction-in-effect
我的代码
$uiq = uniqid();
$image_folder = "/img/articles/original/";
$uploaded = false;
if(isset($_POST['upload_image'])){
if($_FILES['userImage']['error'] == 0 ){
$up = move_uploaded_file($_FILES['userImage']['tmp_name'], $image_folder.$_FILES['userImage']['name']);
if($up){
$uploaded = true;
}
}
}
我的PHPINFO
我的PhpInfo结果表明,我的网络托管空间的根目录在允许的文件夹列表中:
My PhpInfo results show that the root of my web hosting space is in the list of allowed folders:
open_basedir:F:\ PLESK \ WWW \ mydomain.com \ httpdocs \
open_basedir: F:\PLESK\WWW\mydomain.com\httpdocs\
错误
PHP警告:move_uploaded_file():open_basedir限制已生效.文件(/img/articles/original/test.jpg)不在允许的路径内:(F:\ PLESK \ WWW \ mydomain.com \ httpdocs)在F:\ PLESK \ WWW \ mydomain.com \ httpdocs中\ sparklyphp \ cms \ modules \ articles \ edit \ photos \ index.php第40行
PHP Warning: move_uploaded_file(): open_basedir restriction in effect. File(/img/articles/original/test.jpg) is not within the allowed path(s): (F:\PLESK\WWW\mydomain.com\httpdocs) in F:\PLESK\WWW\mydomain.com\httpdocs\sparklyphp\cms\modules\articles\edit\photos\index.php on line 40
更多错误
如果我改变路径
$image_folder = "/img/articles/original/";
到
$image_folder = "img/articles/original/";
我收到其他错误:
PHP Warning: move_uploaded_file(): open_basedir restriction in effect. File(C:\Windows\Temp\php393F.tmp) is not within the allowed path(s): (F:\PLESK\WWW\mydomain.com\httpdocs\) in F:\PLESK\WWW\mydomain.com\httpdocs\sparklyphp\cms\modules\articles\edit\photos\index.php on line 40
PHP Warning: move_uploaded_file(): open_basedir restriction in effect. File(C:\Windows\Temp\php393F.tmp) is not within the allowed path(s): (F:\PLESK\WWW\mydomain.com\httpdocs\) in F:\PLESK\WWW\mydomain.com\httpdocs\sparklyphp\cms\modules\articles\edit\photos\index.php on line 40
PHP Warning: move_uploaded_file(C:\Windows\Temp\php393F.tmp): failed to open stream: Operation not permitted in F:\PLESK\WWW\mydomain.com\httpdocs\sparklyphp\cms\modules\articles\edit\photos\index.php on line 40
PHP Warning: move_uploaded_file(): Unable to move 'C:\Windows\Temp\php393F.tmp' to 'img/articles/original/test.jpg' in F:\PLESK\WWW\mydomain.com\httpdocs\sparklyphp\cms\modules\articles\edit\photos\index.php on line 40
**托管环境**网站托管环境是Windows 2008 R2机器,带有Plesk 11.5(最新版本/更新),在FastCGI模式下运行PHP 5.4.16.我对整个服务器拥有完全管理员权限.
** Hosting Environment **The website hosting environment a Windows 2008 R2 box with Plesk 11.5 (the latest version/update) running PHP 5.4.16 in FastCGI mode. I have full admin access to the entire server.
最令人沮丧的是文件正在上传到temp文件夹,我只是无法从那里获取它!
The most frustrating thing here is that the file is being uploaded to the temp folder, I just can't get it from there!
任何帮助将不胜感激!
鲍勃
推荐答案
此:
PHP Warning: move_uploaded_file(): open_basedir restriction in effect.
File(C:\Windows\Temp\php393F.tmp) is not within the allowed path(s):
(F:\PLESK\WWW\mydomain.com\httpdocs\) in
F:\PLESK\WWW\mydomain.com\httpdocs\sparklyphp\cms\modules\articles\edit\photos\index.php on line 40
基本上是说甚至您的临时文件夹也不允许. AFAIK显然是错误的配置,您应该联系您的主机来修复它.或者,如果您像说的那样拥有完全的管理员访问权限,只需将open_basedir限制更改为合理即可. 此页面似乎包含有关更改/删除open_basedir设置的说明.
is basically saying even your temp folder is not allowed. AFAIK that would be clearly a misconfiguration and you should contact your hosting to fix it. Or, if you have full admin access like you say you have, just change the open_basedir restriction to something sane. This page looks to contain instrcutions on changing/removing open_basedir settings.
这篇关于在Windows的Plesk中有效的open_basedir限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!