public function get($name, $arrayOffset = null)
{
// first some validations
if (!$this->fileBag->keyExists($name)) {
throw new FilesException('Upload field with name "' . $name . '" was not found in the $_FILES array.');
}
// check to see if we have already created the file object
if (isset($this->fileObject[$name])) {
$fileObject = $this->getFileObject($name, $arrayOffset);
if ($fileObject) {
return $fileObject;
}
}
// create and return File object
$file = $this->fileBag->key($name);
if (is_null($arrayOffset)) {
$fileObject = $this->createFileObject($file, $arrayOffset);
return $fileObject;
} else {
if (!isset($file['name'][$arrayOffset])) {
throw new FilesException('Uploaded file with name "' . $name . '" and
offset "' . $arrayOffset . '" was not found in the $_FILES array.');
}
$fileObject = $this->createFileObject($file, $arrayOffset);
return $fileObject;
}
}