Warning: fread(): Length parameter must be greater than after filesize

问题描述 投票:0回答:0

**我正在使用我的 php 脚本文件 phpscript.php 将我的 kubectl 命令输出存储到一个文件 data.txt 中

当我从 centOS 终端运行时我的脚本工作正常 但在通过 chrome 浏览器运行时出现以下错误。

我的php脚本文件位置[根目录] --> root:root /var/www/html/phpscript.php 我的data.txt文件位置[rbind(非root)目录]--> rbind:rbind /data_php/data.txt

**

浏览器错误: 拉文德拉 警告:fread(): Length parameter must be greater than 0 in /var/www/html/testscript/stact.php on line 18

绑定


phpscript.php代码:

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);


$namespace="ravindra";

echo "$namespace";

$result=shell_exec("kubectl --kubeconfig /data_php/config get pod -n $namespace");

file_put_contents('/data_php/data.txt', $result);

$myfile = fopen("/data_php/data.txt", "r") or die("Unable to open file!");

$out = fread($myfile,filesize("/data_php/data.txt"));
echo "<pre> $out</pre>";

fclose($myfile);


echo get_current_user();
?>

我的观察: 这个问题是由于权限问题。 请提出解决此问题的解决方案。 感谢未来。

我也在尝试在浏览器上显示 kubctl 命令输出结果。

请帮我解决这个问题。

php shell-exec
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.