メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Validation::upload

Check that a file was uploaded

Description​

public boolean Validation::upload( string $name, mixed $code )

Valid when $_FILES[$name] exists, has no upload error and is not empty. Unlike the other checks, it is not skipped when nothing was posted. To save the file and check its size and type, use Upload.

Arguments​

NameData typeDefaultRemarks
$namestringname attribute of the input[type="file"] (also the key of the error message)
$codemixedError code, array of error code and parameters, or error message

Example​

Controller
use Fegg\Validation;

$validation = new Validation();

$validation->upload('image', '<strong>Image</strong> を選択してください');

if ($validation->isError()) {
// No file was uploaded
}