title: open_basedir restriction in effect in Plesk for Windows
body: <p>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!</p>
  
  <p>I can see it hit the c:/windows/temp/ folder <strong>every time</strong> so its only falling over when trying to perform the <strong>move_uploaded_file</strong> operation.</p>
  
  <p>After much research I know what this is and in theory how to fix it having read a number of pages online such as:</p>
  
  <p><a href="http://forum.parallels.com/showthread.php?258036-Plesk-Windows-open_basedir-restriction-in-effect" rel="nofollow">http://forum.parallels.com/showthread.php?258036-Plesk-Windows-open_basedir-restriction-in-effect</a></p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>$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;   
          }
      }
  }
  </code></pre>
  
  <p><strong>My PHPINFO</strong></p>
  
  <p>My PhpInfo results show that the root of my web hosting space is in the list of allowed folders:</p>
  
  <p>open_basedir: F:\PLESK\WWW\mydomain.com\httpdocs\</p>
  
  <p><strong>The Error</strong></p>
  
  <p>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</p>
  
  <p><strong>More Errors</strong></p>
  
  <p>If I change my path</p>
  
  <pre><code>$image_folder = "/img/articles/original/";
  </code></pre>
  
  <p>to</p>
  
  <pre><code>$image_folder = "img/articles/original/";
  </code></pre>
  
  <p>I get additional errors:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>** 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.</p>
  
  <p>The most frustrating thing here is that the file is being uploaded to the temp folder, I just can't get it from there!</p>
  
  <p>Any help would be much appreciated!</p>
  
  <p>Bob</p>