Display file if it exists on the server

If we need to display a list of files so that we can access them via the link, it is recommended to display those links only if the files exist.

Thus, in the first phase, we define the path to the respective files. For example, let’s say it’s a folder with some pdfs. Because we need to get to the path on the HDD, not the URL, we will use the $_SERVER[‘DOCUMENT_ROOT’] variable.

As you can see, the link itself does not need the $_SERVER [‘DOCUMENT_ROOT’] variable.

Source: shorturl.at/mwFW7

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply

Your email address will not be published. Required fields are marked *