in reply to Download file to browser
When the browser requests https://www.my-website.com/download.pl?file=path1/path2/filename.ext , you need to respond with the Content-Disposition header. Depending on what way you use to send headers, this might need different code. For Mojolicious, you send headers like the following:
use File::Basename 'basename'; ... # Serve static file if it exists if (my $asset = $c->app->static->file('path1/path2/filename.ext')) { $c->res->headers->content_disposition('attachment; filename=filena +me.ext'); $c->reply->asset($asset); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Download file to browser
by david.woosley (Initiate) on Apr 19, 2024 at 16:47 UTC | |
by Corion (Patriarch) on Apr 19, 2024 at 17:16 UTC | |
by eyepopslikeamosquito (Archbishop) on Apr 20, 2024 at 08:06 UTC | |
by Fletch (Bishop) on Apr 20, 2024 at 08:14 UTC | |
by marto (Cardinal) on Apr 19, 2024 at 22:49 UTC |