Send the contents of the given filename to the current http connection
This function utilizes the $config->fileContentTypes to match file extension to content type headers and force-download state.
This function throws a WireException if the file can’t be sent for some reason. Set the throw option to
false if you want it to instead return integer 0 when errors occur.
Usage
// basic usage$int = $files->send($filename);
// usage with all arguments$int = $files->send($filename, array$options= [], array$headers= []);
Arguments
Name
Type(s)
Description
filename
string, bool
Full path and filename to send or boolean false if provided in $options[data].
options (optional)
array
Optional options to modify default behavior:
exit(bool): Halt program execution after file send (default=true).
partial(bool): Allow use of partial downloads via HTTP_RANGE requests? Since 3.0.131 (default=true)
forceDownload(bool|null): Whether file should force download, or null to let content-type header decide (default=null).
downloadFilename(string): Filename you want the download to show on user’s computer, or omit to use existing (default='').
headers(array): The $headers argument to this method can also be provided as an option right here (default=[]). Since 3.0.131.
data(string): String of data to send rather than file, $filename argument must be false (default=''). Since 3.0.132.
limitPath(string|bool): Prefix disk path $filename must be within, false to disable, true for site/assets (default=false). Since 3.0.169.
throw(bool): Throw exceptions on error? When false, it will instead return integer 0 on errors (default=true). Since 3.0.169.
headers (optional)
array
Optional headers that are sent, below are the defaults:
ProcessWire Weekly #559 The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
Weekly.pw / 25 January 2025
ProcessWire 3.0.244 new main/master version ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
Blog / 18 January 2025
Subscribe to weekly ProcessWire news
“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani