Return a new temporary directory/path ready to use for files
- The temporary directory will be automatically removed at the end of the request.
- Temporary directories are not http accessible.
- If you call this with the same non-empty
$name
argument more than once in the same request, the sameWireTempDir
instance will be returned.
Example
$tempDir = $files->tempDir();
$path = $tempDir->get();
file_put_contents($path . 'some-file.txt', 'Hello world');
Usage
// basic usage
$wireTempDir = $files->tempDir();
// usage with all arguments
$wireTempDir = $files->tempDir($name = '', $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
name (optional) | Object, string | Any one of the following: (default='')
|
options (optional) | array, int | Deprecated argument. Call |
Return value
WireTempDir
Returns a WireTempDir instance. If you typecast return value to a string, it is the temp dir path (with trailing slash).
API reference based on ProcessWire core version 3.0.236