HI I'm calling file()
or file_get_contents()
functions, it works fine in apache server but then i shifted my site to windows server but now it returns error.
Warning: file(): open_basedir restriction in effect. File(/base/data/user/filename.json) is not within the allowed path(s): (C:\inetpub\wwwroot) in C:\inetpub\wwwroot\login.php on line 14
Here the code line <?php $update= json_decode(file("base/data/user/$username.json"));?>
Asked
Active
Viewed 35 times
0

Abhishek Joshi
- 11
- 3
-
What's the value of `open_basedir` in your `php.ini`? Clearly the error message asks you to review that. – Lex Li Jun 08 '22 at 05:13
-
1The `open_basedir` directive was a last resort fix for poorly configured shared hosting services. It seems to be your own server, you don't need to use it. – Álvaro González Jun 08 '22 at 06:20
-
```open_basedir="C:\inetpub\wwwroot\"``` this value – Abhishek Joshi Jun 08 '22 at 06:32
-
Does this answer your question? [open\_basedir restriction in effect. File(/) is not within the allowed path(s):](https://stackoverflow.com/questions/1846882/open-basedir-restriction-in-effect-file-is-not-within-the-allowed-paths) – CBroe Jun 08 '22 at 07:06
-
1Is the code you provided the original code? – shingo Jun 08 '22 at 07:19
-
No Solution for iis server. – Abhishek Joshi Jun 08 '22 at 07:36
-
@shingo That's the line number where I'm getting error. – Abhishek Joshi Jun 08 '22 at 07:42
-
Shingo is asking because your code shows a relative path (`base/data/user/...`) but the error message shows an absolute path (`/base/data/user/...`). The path could be forbidden for the sole reason of being _wrong_. Also, are you positively sure you need to use `open_basedir()`? What problem are you trying to solve with that? – Álvaro González Jun 09 '22 at 14:52