Answer the question
In order to leave comments, you need to log in
How to properly open a file in PHP on IIS?
You need to open the file in IIS.
This code opens without problems
$filename = 'C:/web/files/test.txt'';
file_get_content($filename);
$filename = $_SERVER['DOCUMENT_ROOT'] . '/files/test.txt';
file_get_content($filename);
Warning: file_get_contents(C:\web/files/test.txt): failed to open stream: No such file or directory in
$filename = addslashes($_SERVER['DOCUMENT_ROOT'] . '\\files\\test.txt');
file_get_content($filename);
Answer the question
In order to leave comments, you need to log in
You can try doing str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']); - once with straight lines initially works.
But I wouldn't recommend using DOCUMENT_ROOT at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question