Home > Article > Backend Development > Query whether a certain pdf file exists in the server
Dear masters, please provide a query to see if a certain pdf file exists in the server. If it exists, it will be opened. If it does not exist, the user will be prompted to re-enter.
Dear masters, please provide a query to see if a certain pdf file exists in the server. If it exists, it will be opened. If it does not exist, the user will be prompted to re-enter.
Make a judgment first and then perform the corresponding operation.
<code>$fileName = "text.pdf"; if(file_exists($fileName)) { Header("Location: $fileName"); } else { echo '<script> alert("文件不存在") </script>'; //die(json_encode(array("code"=> 404, "message"=> "文件不存在"))); }</code>