在 public_html 之外的目录中读取文件

佩尔

我正在尝试读取文件夹外的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 文件没有访问该文件的权限,我怎样才能使其有权访问该文件?

米拉德·埃利亚斯

尝试通过关系路径访问您的文件。

例如您的文件夹结构是:

-folder
   --new.txt
 
-public_html
   --reader.php

在您的 reader.php 中:

<?php
    $file = '../folder/new.txt';
    
    $fileHandle = file_get_contents($file);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在 public_html 之外存储图像

将文件包含在与public_html平行的目录中

当cron文件位于public_html目录之外时,cron作业不起作用

将网站文件放在 public_html 中是否安全

将公共目录更改为 public_html 后的 Laravel

在public_html上托管laravel并避免人们访问文件

当public_html上存在文件时,apache $ 1失败

将各种视频文件上传到public_html

即使我在组中也无法写入public_html

.php文件不在/ home / USER / public_html文件夹之外执行

PHP文件,根目录或public_html目录放在哪里?

PHP回显存储在特定div中“public_html”之外的图像

laravel - index.php 不能要求 public_html 文件夹中的特定文件

PHP - 如何確定文件在 public_html 文件夾中?

将用户添加到/ public_html /中的特定文件夹

如何上传public_html中的图像而不是laravel的项目文件?

WordPress项目旁边的Laravel项目(位于public_html文件夹中)

php composer无法在public_html文件夹中访问

如何在Laravel 5中将公用文件夹更改为public_html

在Java中的/ public_html /下的Web服务器内创建文件夹

将Laravel项目文件保存在public_html中是否不安全?

设置ftp帐户以仅访问public_html中的一个文件夹

在每个 /home/userxxx/public_html/.htaccess 文件中添加行

500 OOPS:无法更改目录:/ home / user / public_html,VSFTPD错误

Symfony 4.x公共目录重命名为public_html

.htaccess从root(public_html)重定向到子目录,并拒绝直接访问root

将图像上传到Public_html文件而不是公共项目文件

URL 在文件名之前总是有 public_html

如何在共享托管中将laravel项目指向public_html下的公共文件夹