Answer the question
In order to leave comments, you need to log in
How to implement downloading files from the server to the client?
The downloads are located outside the project folder. I can't figure out how to get the file in this case.
Answer the question
In order to leave comments, you need to log in
If they are within the server, you can go up to the directory above ( ../ )
There must be read permissions from this directory
ps which is fundamentally wrong.
If on another server, then as "absolute links" have already written
Probably it's not about the paths, but about downloading?
Here it may be:
function downloadFile($file, $fileName, $ctype) {
if (file_exists($file)) {
if(ob_get_level()!==0) ob_clean();
header('Content-Description: File Transfer');
header('Content-Type: '.$ctype.'');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . $fileName);
readfile($file);
unlink($file);
exit;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question