Andrew13\Cabinet\CabinetUpload::upload PHP Method

upload() public method

Handles folder creation.
public upload ( Symfony\Component\HttpFoundation\File\UploadedFile &$file ) : array
$file Symfony\Component\HttpFoundation\File\UploadedFile
return array
    public function upload(UploadedFile &$file)
    {
        // Check the upload type is valid by extension and mimetype
        $this->verifyUploadType($file);
        // Get the folder for uploads
        $folder = $this->getUploadFolder();
        // Check file size
        if ($file->getSize() > static::$app['config']->get('cabinet::max_upload_file_size')) {
            throw new FileException('File is too big.');
        }
        // Check to see if file exists already. If so append a random string.
        list($folder, $file) = $this->resolveFileName($folder, $file);
        // Upload the file to the folder. Exception thrown from move.
        $file->move($folder, $file->fileSystemName);
        // If it returns an array it's a successful upload. Otherwise an exception will be thrown.
        return array($this->cleanPath(static::$app['config']->get('cabinet::upload_folder')) . $this->dateFolderPath, $file->fileSystemName);
    }