0

Following this answer, I added the path in the php.ini file, but I'm still getting the below warning/error message:

Warning: scandir(): open_basedir restriction in effect. File(S:\Docs) is not within the allowed path(s): (C:\inetPub;S:\Docs) in C:\inetpub\somewhere.com\cr\test.php on line 25

Warning: scandir(S:\Docs): failed to open dir: Operation not permitted in C:\inetpub\cr\somewhere.com\test.php on line 25

Warning: scandir(): (errno 1): Operation not permitted in C:\inetpub\somewhere.com\cr\test.php

I was told that the S:/ drive is not on the Microsoft IIS webserver that web files are hosted on and it is a Linux NAS that requires a username & password to get into it. It has been mapped to the webserver, but can't seem to access it via PHP. The person who told me this information works in network and says it's a path problem, which falls in my domain, but I'm thinking it's a permission thing, which goes back to him, passing the hot potato of accessing this drive back & forth for a week. Neither of us can seemingly bridge the gap.

The PHP code:

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

 $files = scandir('S:\Docs');
 var_dump($files);

 $filename = 'S:\Docs\cr\text.pdf';

 if (is_readable($filename)) {
   echo 'good';
 } else {
  echo 'bad';
 }
?>

So my question is the title: What are the possible reasons as to why a PHP operation is not permitted?

new information: So I added the is_readable() function suggested by someone in the comments. Below is the new error:

is_readable(): open_basedir restriction in effect. File(S:\Docs\cr\text.pdf) is not within the allowed path(s): (C:\inetPub;S:\Docs) in C:\inetpub\somewhere.com\cr\test.php on line 34

Any reasons as to why this happening?

hnewbie
  • 151
  • 1
  • 15
  • "failed to open dir: Operation not permitted" seems like your process does not have read access on the S:\Docs. – Ritesh Jul 27 '18 at 15:22
  • 2
    the is_readable() function could maybe tell you if you have access to it / it exists : http://php.net/manual/fr/function.is-readable.php – NanoPish Jul 27 '18 at 15:22
  • 1
    @Ritesh we have the everyone group under security on the S: drive. It has all been checked except for full control and special permissions. So read, write, and all those other permission have been checked. – hnewbie Jul 27 '18 at 15:27
  • 1
    @NanoPish updated my question. – hnewbie Jul 27 '18 at 16:04
  • 2
    @hnewbie this output seems to mean that you have no read right over that directory. Try is_readable with 'S:', 'S:'Docs', 'C:' to understand what you are allowed to read currently ? – NanoPish Jul 27 '18 at 16:11
  • 1
    @NanoPish Thank you for following up. I'm able to use readable() function on a path that we are actually connected to. How would I get the read/write permission on that S:drive directory? I even dropped down and tried the drive, S: drive, I can't seem to access it. – hnewbie Jul 27 '18 at 16:21
  • 2
    @hnewbie okay so you have no permission over that disk / path. You should configure php / server and / or OS to gain access. I will post an answer to try to give solutions – NanoPish Jul 27 '18 at 16:27
  • @NanoPish thank you! – hnewbie Jul 27 '18 at 16:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/176900/discussion-between-hnewbie-and-nanopish). – hnewbie Jul 27 '18 at 18:54

1 Answers1

0

Check whether "open_basedir" is set in INI file which points to a diffeernt directory.

Basically, open_basediris used to limit or restrict the directory access.