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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-09-19 09:16:31
Original
1320 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
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template