Home > Backend Development > PHP Tutorial > Query whether a certain pdf file exists in the server

Query whether a certain pdf file exists in the server

WBOY
Release: 2016-09-19 09:16:31
Original
1281 people have browsed it

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.

Reply content:

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>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template