我正在嘗試讀取檔案夾外的public_html檔案。
$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 '';
}
我認為 php 檔案沒有訪問該檔案的權限,我怎樣才能使其有權訪問該檔案?
uj5u.com熱心網友回復:
嘗試通過關系路徑訪問您的檔案。
例如您的檔案夾結構是:
-folder
--new.txt
-public_html
--reader.php
在您的 reader.php 中:
<?php
$file = '../folder/new.txt';
$fileHandle = file_get_contents($file);
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/490098.html
上一篇:更改日期時間選擇器輸出格式
下一篇:使用bash從變數中洗掉字串
