Unlink/delete file with additional protections relative to PHP unlink()
This method requires a full pathname to a file to unlink and does not accept any kind of relative path traversal.
This method will be limited to unlink files only in /site/assets/ if you specify
true
for the$limitPath
option (recommended).
Available since version 3.0.118.
Usage
// basic usage
$bool = $files->unlink(string $filename);
// usage with all arguments
$bool = $files->unlink(string $filename, $limitPath = false, bool $throw = false);
Arguments
Name | Type(s) | Description |
---|---|---|
filename | string | |
limitPath (optional) | string, bool | Limit only to files within some starting path? (default=false)
|
throw (optional) | bool | Throw exception on error? |
Return value
bool
True on success, false on fail
Exceptions
Method can throw exceptions on error:
WireException
- If file is not allowed to be removed or unlink fails
API reference based on ProcessWire core version 3.0.236