I'm trying to read a file outside of the public_html
folder.
$file = '/var/www/new.txt';
$fileHandle = file_get_contents($file);
if($result)
{
$o = mysqli_num_rows($result);
if ($o)
readfile($file);
else
echo 'Error authenticating please contact support';
}
else {
echo '';
}
I think the php file doesn't have permissions to access this file, how would I be able to make it have access to this file?
CodePudding user response:
try to access your file via relational path.
for example your folder structure is:
-folder
--new.txt
-public_html
--reader.php
in your reader.php :
<?php
$file = '../folder/new.txt';
$fileHandle = file_get_contents($file);