Documentation

FileSystem extends Base
in package

FileSystem Storage

This class uploads files to a designated directory on the filesystem.

Tags
author

Josh Lockhart info@joshlockhart.com

since
1.0.0

Table of Contents

Properties

$directory  : string
Upload directory
$overwrite  : bool
Overwrite existing files?

Methods

__construct()  : mixed
Constructor
upload()  : bool
Upload
moveUploadedFile()  : bool
Move uploaded file

Properties

$directory

Upload directory

protected string $directory

$overwrite

Overwrite existing files?

protected bool $overwrite

Methods

__construct()

Constructor

public __construct(string $directory[, bool $overwrite = false ]) : mixed
Parameters
$directory : string

Relative or absolute path to upload directory

$overwrite : bool = false

Should this overwrite existing files?

Tags
throws
InvalidArgumentException

If directory does not exist

throws
InvalidArgumentException

If directory is not writable

upload()

Upload

public upload(File $file[, string $newName = null ]) : bool
Parameters
$file : File

The file object to upload

$newName : string = null

Give the file it a new name

Tags
throws
RuntimeException

If overwrite is false and file already exists

Return values
bool

moveUploadedFile()

Move uploaded file

protected moveUploadedFile(string $source, string $destination) : bool

This method allows us to stub this method in unit tests to avoid hard dependency on the move_uploaded_file function.

Parameters
$source : string

The source file

$destination : string

The destination file

Return values
bool
✖ Error 404 while fetching file: ✖ Error 404 while fetching file: 
On this page

Search results