The command is expecting a local file path and not a URL
Some options here https://stackoverflow.com/questions/38791635/download-a-file-in-laravel-using-a-url-to-external-resource
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want people to be able to download files from CDN. When the user clicks 'Download' button on my app, I initiated an ajax request to the server. On the server I've -
public function download(Resource $resource) {
// Force download of the file
$file_to_download = 'https://data.domain.com/downloads/' . $resource->file_name;
return response()->download($file_to_download);
}
I've double checked that the file actually is available on the https://data.domain.com/downloads/filename.ext and is accessible from browser. Yet, Laravel reports the following error -
"Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException"
The URL reported by the error is actually correct, and file does exist on that location. Can someone tell me what am I missing?
Would really appreciate your responses.
Please or to participate in this conversation.