I have a php script that takes a file’s id in the url, finds the link for the file from an sql database, and then streams the file.
On the client’s page, they click a link and are then prompted to download a file. If the file wasn’t in the database, I would like to prevent the browser from changing the page to a 404 or other type of error page, but rather keep the client’s page where it is.
Is there an HTTP status or content-type that will tell the browser to not load the page? Would doing something like setting the content-length to 0 work?
Return that status code, and the browser will stay on the page it was on.