Skip to content

Miscellaneous

sendFile()

sendFile() — returns any

Sends a file to the user (from the files folder or a path relative to it by default).

NameTypeRequiredDefaultDescription
filestringyesThe file to send to the user.
namestringyesThe file name to show in the browser download dialog box.
typestringyesThe HTTP content type to deliver the file as.
dispositionstringyesattachmentSet to inline to have the browser handle the opening of the file (possibly inline in the browser) or set to attachment to force a download dialog box.
directorystringyesDirectory outside of the webroot where the file exists. Must be a full path.
deleteFilebooleanyesfalsePass in true to delete the file on the server after sending it.
// Send a PDF file to the user
sendFile(file="wheels_tutorial_20081028_J657D6HX.pdf");

// Send the same file but give the user a different name in the browser dialog window
sendFile(file="wheels_tutorial_20081028_J657D6HX.pdf", name="Tutorial.pdf");

// Send a file that is located outside of the web root
sendFile(file="../../tutorials/wheels_tutorial_20081028_J657D6HX.pdf");