Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Digisol's avatar

Problem Having User Download a File

I'm attempting to have laravel download a file during an ajax call. Everything is running smoothly with no errors, however no file is downloaded on the user's side. The check on the if statement is returning as true, so the file is there.

$file = 'json/fs_'.strtolower($entry->country).'.json';


            if(Storage::disk('public')->exists($file)){
                Storage::disk('public')->delete($file);
                Storage::disk('public')->put($file, json_encode($entry));
    
            }
        }


        Storage::disk('public')->download($file);
        
        return response()->json(['success' => $country]);
0 likes
1 reply

Please or to participate in this conversation.