Jump to content

Redirecting a page URL to a file


cb2004
 Share

Recommended Posts

8 hours ago, cb2004 said:

However I tried using $http->sendfile and $files->send as I thought they would be better but they didn't work.

Both of these are the same and they work like this:

$files->send($page->file->filename);

And you can force the download for file types that might otherwise open in the browser like this:

$files->send($page->file->filename, ['forceDownload' => true]);

 

  • Like 1
Link to comment
Share on other sites

10 hours ago, Robin S said:

And you can force the download for file types that might otherwise open in the browser like this:


$files->send($page->file->filename, ['forceDownload' => true]);

 

In addition to this – depending on the context where one uses it –, one might need other options too, see:

https://processwire.com/api/ref/wire-http/send-file/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...