K
K
Konstantin2019-03-31 20:19:26
Laravel
Konstantin, 2019-03-31 20:19:26

How to download a file by full path?

On the client, I get a response from the server with the full path to the file:

{file: "C:\Projects\events\Backend\storage\app/events/events_31-03-19.xlsx"}

I try to tell the browser to download it like this:
window.location.href = res.file;
But with no result.
The server side is as follows:
return \Response::json(["file" => storage_path('app/'.$path.$filename)]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danny Chase, 2019-04-01
@Dase23

Firstly, response should not be in json. symfony response has a binary method that will return a file upload.
Second, check out the laravel storage documentation. Very handy bike protection mechanism

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question