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

Upload::getUploadedData

Get the information of the uploaded file

Description​

public mixed Upload::getUploadedData( string $name )

Returns an array describing the file saved by Upload::upload, or null when no file was saved for $name.

KeyRemarks
nameSaved file name ($up_name + extension)
org_nameOriginal file name
typeMIME type
sizeFile size (bytes)
up_timeUpload time (Unix timestamp)
widthImage width (images only)
heightImage height (images only)
attrwidth="..." height="..." string (images only)

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_'))) {
$data = $upload->getUploadedData('image');
// $data['name'] -> "i_65f0c3a1b2c4d.jpg"
}