Server action: Adding php readfile

Hi,

I am building a GET server action download.php that should do the following:

  1. Restrict access to loggedin users
  2. Check the attachments table to see if the $GET.attachment_ID is owned by the loggedin user ({{siteSecurity.identity}}
  3. Retrieve the file path from the attachments table
  4. Output the corresponding file using the readfile php function

While it is straightforward to do steps 1, 2 and 3 using Wappler, I am not able to do step 4.

I tried following: Secure File Download from a path outside of website root but their case is different as they use $POST and have their files outside of the website root (mines are inside)

Can you please advise on the most straightforward way to do readfile in Wappler?

Community Page
Last updated: