有人能解释一下为什么当我在下面的脚本中发布原始数据(例如"test.txt“)时
<?php
echo file_get_contents("php://input");
?>它只打印文本"test.txt“而不是该文件的文件内容?
谢谢
发布于 2014-05-30 11:04:55
您的代码读取原始POST数据的内容并回显它。
而你想要的是:
// retrieve the requested filename
$fileName = file_get_contents("php://input");
// echo the contents of the requested file
echo file_get_contents($fileName);根据您要尝试的内容,您可能希望对$fileName输入进行消毒(未显示:太宽),并限制对特定本地目录的访问:
$path = $myLocalDirectory . DIRECTORY_SEPARATOR . $fileName;
if (file_exists($path) {
echo file_get_conents($path);
}发布于 2014-05-30 11:07:19
就像这样..。
$input = "abc.txt";
echo file_get_contents($input);它给出了文本文件abc.txt的内容
https://stackoverflow.com/questions/23952981
复制相似问题