A
A
Andrew2020-05-01 21:47:22
PHP
Andrew, 2020-05-01 21:47:22

How to set "do nothing" in PHP if a broken link is specified?

The site added a script to hide links.
Implemented like this:
1) all links for downloading files lead to download.php with a GET request (with file ID data)
2) a link is taken on the download page by file ID
3)

header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="File"');
readfile($link);

4) and so the file is downloaded without reloading the page.

Now a check for 404 has been added. To prevent redirects, we update the page by $_SERVER['HTTP_REFERER']
How to make sure that the page is not updated if the link returns 404? (and did not follow the link).
Maybe the Content-type is different? (tried text/plain, none...)
Thanks.

PS We want to do this, not ajax.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2020-05-01
@prolisk

if (нету файла) {
        header('HTTP/1.0 204 No Content');
        exit;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question