I am trying to build a text file loader. User can type any word in text input and it will be called $name. I have the text files on my server. But when I type in the words that I don't have, It shows me this.
Warning: file_get_contents(./files/kkk): failed to open stream: No such file or directory
I just trying to ignore the warning. I even try this way. But I am still getting that warning.
if (file_get_contents("./files/".$name,"UTF-8") === false){
echo'';
}
This is the code that I have. I am sorry for my english.
<?php
if(empty($_POST["name"])) {
echo '';
}
else{
echo '';
}
$name = $_POST["name"];
if (file_get_contents("./files/".$name,"UTF-8") === false){
echo'';
}
else {
echo "<div id='html1' >";
echo file_get_contents("./files/".$name,"UTF-8");;
echo "</div>";
}
?>
Problem was fix using is_file
and I removed UTF-8 to use is_file
.