PHP open_basedir restriction: (file) is not within the allowed path

1.3k Views Asked by At

Previously, I had attempted to upload and view files from another drive, see here.

The web files were on the htdocs folder on the C: drive, but I needed to be able to save to a folder on the D: drive. I was successful completing this task.

By updating the open_basedir portion in the php.ini file, I simply added the additional extension like this:

open_basedir = 'C:\inetPub;D:\CargoDocsPDFs;'

Then, I can use PHP's scandir to make sure I can see the folders in the D: drive, as follows:

<?php
$files1 =  scandir('D:/CargoDocsPDFs');
var_dump($files1);
?>

Which gives me the following:

array(6) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) "000000000" [3]=> string(10) "0000000000" [4]=> string(10) "0001782136" [5]=> string(10) "0004670615" }

Here is where my new problem begins...

We've been given a new drive to upload and view files from. It's a network drive allocated with more space the previous D: drive.

The new network drive has been labeled as the S: drive. So I figure I could simply update the php.ini file again:

open_basedir = 'C:\inetPub;S:\CargoDocsPDFs'

Then I run the same PHP scandir function (with error reporting on):

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

//$files1 =  scandir('D:/CargoDocsPDFs');
$files2 =  scandir('S:/CargoDocsPDFs');

//var_dump($files1);
var_dump($files2);
?>

But I am getting the following errors:

Warning: scandir(): open_basedir restriction in effect. File(S:/CargoDocsPDFs) is not within the allowed path(s): (C:\inetPub;S:\CargoDocsPDFs) in C:\inetpub\mylocation\CargoReadiness\test.php on line 14

Warning: scandir(S:/CargoDocsPDFs): failed to open dir: Operation not permitted in C:\inetpub\mylocation\CargoReadiness\test.php on line 14

Warning: scandir(): (errno 1): Operation not permitted in C:\inetpub\mylocation\CargoReadiness\test.php on line 14

bool(false)

Why am I getting this new found error, and how do I fix it?

Edit

Here are the how the privileges are set in the 2 drives below. The properties on the left is the drive I am trying to connect to, which is the S: drive, and a network drive. The properties on the right is the D: drive, and is the drive that I can successfully upload and view the PDFs.

enter image description here

If you'll notice the S: drive, the privileges for Everyone are all checked except for Special Permissions (Full Control is also unchecked, but you cannot see it in the pic). Whereas the D: drive, the only privileges checked is Special Permissions.

I am not sure if this has anything to do with my error.

Edit 2

It has been revealed to me that the device I have been trying to connect to is a NAS device. I am not sure what that means, nor do I know if the current issue at hand is related to why I cannot connect to the device.

0

There are 0 best solutions below