1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
John Beasley
  • 2,577
  • 9
  • 43
  • 89
  • Your user, which executes the PHP code is probably not having the privilege to access the new drive. – Lajos Arpad Jul 13 '18 at 21:45
  • have You tried with: `$files2 = scandir('S:\CargoDocsPDFs');` ? I mean maybe it's checking forward and backslashes for network drive? or try with glob: `$files2 = glob('S:\CargoDocsPDFs\*');` – num8er Jul 13 '18 at 22:12
  • @LajosArpad - Any thoughts on how I can adjust the privileges? – John Beasley Jul 16 '18 at 12:44
  • @num8er - When I use glob, the output is: array(0) { }. Any thoughts? – John Beasley Jul 16 '18 at 12:45
  • @num8er - I made a couple of updates. I am hoping you would take a look. – John Beasley Jul 26 '18 at 20:20
  • Very dumb idea: You added "S:\CargoDocsPDFs" to the open_basedir. But PHP complains that it cannot open "S:/CargoDocsPDFs". See the difference? Try adding the folder with a slash instead of a backslash to the open_basedir and try if it works... Maybe thats some weird quirk because its a network drive? I'm not sure but its worth a shot... – Christian Engel Aug 01 '18 at 21:16

0 Answers0