0
votes

I'm running Xampp on my windows 10 machine, and I have a file called files.txt inside my directory project.

[...]storage\app\public

My config/filesystem.php looks like:

    'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
        'permissions' => [
            'file' => [
                'public' => 0664,
                'private' => 0600,
            ],
            'dir' => [
                'public' => 0775,
                'private' => 0700,
            ],
        ],
    ],

On my controller I am calling the file to download

return response()->download(storage_path("app\public\\files.txt"),'down.txt');

I am receiving 200 status Ok, the headers content I receive:

Content-Disposition: attachment; filename=files.txt , on response on the browser Xhr devtools I could see the content of the file, but unhappy the download don't happen.

1
Double back splash before files.txt. change to app\public\files.txtPrince Dorcis

1 Answers

0
votes

Can you try to specify header :

$content = storage_path("app\public\files.txt");
$fileName = 'down.txt';
$headers = [
  'Content-type' => 'text/plain', 
  'Content-Disposition' => sprintf('attachment; filename="%s"', $fileName),
  'Content-Length' => strlen($content)
];   

return response()->download($content,$fileName, $headers);