I would like to ask is it possible in PHP to detect whether there is an error occurred during the download or the downloading of the file was successful?

In detail, say (for example )I have a site that provides mp3 or video files, and I have an option to download the file, I would like to handle errors during the download that's why I am wondering if this is possible.