Skip to main content
Version: Fegg 5.x (next)

Upload::getErrorMessage

Get the error messages of a file

Description​

public mixed Upload::getErrorMessage( string $name )

Returns the error messages of the last Upload::upload call for $name as an array, or null when there is no error. The messages are defined in file_error_message.php (see Configuration).

Arguments​

NameData typeDefaultRemarks
$namestringname attribute of the input[type="file"]

Example​

Controller
use Fegg\Tool\Upload;

$upload = new Upload();
$upload->setUploadDir($this->config['upload_dir']['path']);

if (!$upload->upload('image', uniqid('i_'), 'Image')) {
var_dump($upload->getErrorMessage('image'));
// -> array('<strong>Image</strong> のサイズが大きすぎます')
}