Handle the file upload. Returns the array on success, or false
on failure.

@param \Symfony\Component\HttpFoundation\File\UploadedFile $file
@param string                                              $path where to upload file

@return array|bool
965290
public function handle(UploadedFile $file, $path = 'files')
    {
        $filesize = $file->getClientSize();
        $mimetype = $file->getClientMimeType();
        $extension = strtolower($file->getClientOriginalExtension());
        $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
        $filename = $fileName.'.'.$extension;
        list($width, $height) = getimagesize($file);

        $filecounter = 1;
        while (Storage::has($path.'/'.$filename)) {
            $filename = $fileName.'_'.$filecounter++.'.'.$extension;
        }
        $path = $file->storeAs($path, $filename);
        $type = Arr::get(config('file.types'), $extension, 'd');

        return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type');
    }
1019637
public static function createFromUploadedFile(UploadedFile $file = null)
    {
        if (!$file instanceof UploadedFile) {
            return;
        }

        $instance = new static();

        self::$generic_file->moveUploadedFile(new File($file,
            $file->getClientOriginalName()), null, $instance);

        return $instance;
    }
807353
public function getUploadFileName(UploadedFile $file)
    {
        if (! is_callable($this->uploadFileName)) {
            return $this->defaultUploadFilename($file);
        }

        return call_user_func($this->uploadFileName, $file);
    }
508385
public function upload($file,$path){
        if( $this->validExt($file->getClientOriginalName())){
            if($file->getClientSize() > ($this->getMaxUploadFileSize() * 1024 * 1024) ){

                $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_SERVER","params"=>array($file->getClientSize()));
                $this->setInfo(array("msg"=>$result));

                if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido server: ".$file->getClientSize());
                return ;
            }elseif($file->getClientSize() > ($this->config['upload']['size_max'] * 1024 * 1024) ){

                $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_PERMITIDO","params"=>array($file->getClientSize()));
                $this->setInfo(array("msg"=>$result));

                if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido: ".$file->getClientSize());
                return ;
            }else{
                if($file->isValid()){
                    $dir = $this->getFullPath().$path;
                    $namefile = $file->getClientOriginalName();
                    $namefile = $this->clearNameFile($namefile);
                    $nametemp = $namefile;
                    if( $this->config["upload"]["overwrite"] ==false){
                        $ext = $this->getExtension($namefile);
                        $i=0;
                        while(true){
                            $pathnametemp = $dir.$nametemp;
                            if(file_exists($pathnametemp)){
                                $i++;
                                $nametemp = $this->removeExtension( $namefile ) . '_' . $i . '.' . $ext ;
                            }else{
                                break;
                            }
                        }
                    }
                    $file->move($dir,$nametemp);
                    $file = new  \SplFileInfo($dir.$nametemp);
                    return $file;
                }
            }
        }else{
            if( $this->config['debug'] ) $this->_log(__METHOD__." - file extension no permitido: ".$file->getExtension());
        }
    }
653128
public function uploadOne(UploadedFile $file, $folder = null, $disk = 'public')
    {
        return $file->store($folder, ['disk' => $disk]);
    }
998445
private function uploadOne(UploadedFile $file)
    {
        try {
            $uploader = new Uploader(['config' => $this->_config]);
            $uploader->up($file);
            $fileInfo = $uploader->getFileInfo();
            $result = [
                'name' => Html::encode($file->name),
                'url' => $fileInfo['url'],
                'path' => $fileInfo['url'],
                'extension' => $file->extension,
                'type' => $file->type,
                'size' => $file->size
            ];
            if ($this->onlyImage !== true) {
                $result['filename'] = $result['name'];
            }

        } catch (Exception $e) {
            $result = [
                'error' => $e->getMessage()
            ];
        }
        return $result;
    }
1126597
public function handleUploadedFile(UploadedFile $file)
    {
        if ($file->getClientOriginalExtension() === 'zip') {
            $tempFolder = $this->extractZip($file);
            $counters = array('new' => 0, 'updated' => 0);
            foreach (scandir($tempFolder) as $path) {
                if (is_file($tempFolder.'/'.$path)) {
                    $fileCounters = $this->importFile($tempFolder.'/'.$path);
                    $counters['new'] += $fileCounters['new'];
                    $counters['updated'] += $fileCounters['updated'];
                }
            }
            unset($tempFolder);
        } else {
            $counters = $this->importFile($file->getRealPath(), $file->getClientOriginalName());
        }

        return $counters;
    }
159211
private function doRequestUpload(UploadedFile $file)
    {
        $tmpDirectory = $this->getApplication()->getTemporaryDir();
        $data = [];

        if (null !== $file) {
            if ($file->isValid()) {
                if ($file->getClientSize() <= $file->getMaxFilesize()) {
                    $data = $this->buildData($file->getClientOriginalName(), $file->guessExtension());
                    $file->move($tmpDirectory, $data['filename']);
                    $data['size'] = round($file->getClientSize() / 1024, 2);
                    if ($imageInfo = @getimagesize( $data['path'])) {
                        if (isset($imageInfo[0]) && isset($imageInfo[1])) {
                            $data['width'] = $imageInfo[0];
                            $data['height'] = $imageInfo[1];
                        }
                    } else {
                        $data['width'] = 0;
                        $data['height'] = 0;
                    }
                } else {
                    throw new BadRequestHttpException('Too big file, the max file size is ' . $file->getMaxFilesize());
                }
            } else {
                throw new BadRequestHttpException($file->getErrorMessage());
            }
        }

        return $data;
    }
1220939
public boolean upload(String path, String fileName, File file) {
		try (InputStream in = FileUtil.getInputStream(file)) {
			return upload(path, fileName, in);
		} catch (IOException e) {
			throw new FtpException(e);
		}
	}
684074
public function getFileParams (UploadedFile $file)
    {
        $params = [];

        if ($this->resourceID)
            $params['id'] = $this->resourceID;
        else
            $params['id'] = Uuid::uuid4 ()->toString ();

        $params['original_name'] = $file->getClientOriginalName ();
        $params['extension']     = '.' . $file->getClientOriginalExtension ();
        $params['path']          = $this->uploadPath . $params['id'] . $params['extension'];
        $params['size']          = $file->getClientSize ();
        $params['mime_type']     = $file->getClientMimeType ();

        return $params;
    }
269285
public function upload($post, $handler, $path = null)
    {
        $result = $this->transferred = null;
        $this->hook->attach('file.upload.before', $post, $handler, $path, $result, $this);

        if (isset($result)) {
            return $result;
        }

        if (!empty($post['error']) || empty($post['tmp_name']) || !is_uploaded_file($post['tmp_name'])) {
            return $this->translation->text('Unable to upload the file');
        }

        $this->setHandler($handler);
        $this->setDestination($path);

        $result = $this->validate($post['tmp_name'], $post['name']);

        if ($result !== true) {
            unlink($post['tmp_name']);
            return $result;
        }

        try {
            $result = $this->finalize($post['tmp_name'], $post['name'], true);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach('file.upload.after', $post, $handler, $path, $result, $this);
        return $result;
    }
200207
private function getFileInfo(UploadedFile $file)
    {
        $fileManager = $this->get('tuna_cms_file.manager.file_manager');
        $filename = $fileManager->generateTmpFilename($file);

        return [
            'path' => $filename,
            'mimeType' => $file->getMimeType(),
            'originalName' => $file->getClientOriginalName(),
        ];
    }
433662
public static function createFromUploadedFile(UploadedFile $file)
    {
        $size = getimagesize($file->getRealPath());

        $image = new Image($file->guessExtension());
        $image->setOriginalFilename($file->getClientOriginalName());
        $image->setMimeType($file->getMimeType());
        $image->setSize(filesize($file->getRealPath()));
        $image->setWidth($size[0]);
        $image->setHeight($size[1]);

        return $image;
    }
21992
@Override
	public boolean upload(String path, File file) {
		Assert.notNull(file, "file to upload is null !");
		return upload(path, file.getName(), file);
	}
1306625
public function moveUpload(UploadedFile $file) {

        // Nest the uploaded file into unique sub directory and a unqiue name
        $path = $this->makeNestedAndUniquePath($file->getClientOriginalName());

        // Move the uploaded file to the destination using Flysystem and return
        // the new path
        $this->manager->move('tmp://'.$file->getFilename(), 'disk://'.$path);

        // Return the URL of the upload.
        return $this->helpers->url($path);
    }
332126
public function up(UploadedFile $file)
    {
        //设置文件名称
        $this->oriName = $file->name;
        //设置文件大小
        $this->fileSize = $file->size;
        $this->fileType = $this->getExtension();
        $this->fullName = $this->getFullName();
        $this->filePath = $this->getFilePath();
        $this->fileName = $this->getFileName();
        $dirName = dirname($this->filePath);
        if (!is_dir($dirName)) {//递归创建保存目录
            FileHelper::createDirectory($dirName, $this->dirMode, true);
        }
        if (!($file->saveAs($this->filePath) && file_exists($this->filePath))) {
            $this->stateInfo = Yii::t('attachment', 'An error occurred while saving the file.');
            return false;
        } else { //移动成功
            $this->saveModel();
            $this->stateInfo = 'SUCCESS';
            return true;
        }
    }
569321
public function uploadFileFromFilesystem(File $file, string $path)
    {
        $dir = sys_get_temp_dir();

        $filename = $dir.'/'.Uuid::uuid4()->toString().'.'.$this->guessExtension($path);

        rename($path, $filename);

        $file->path = $filename;
        $file->save();

        $file->addMedia($file->path)->toMediaCollection('default');

        $result = new Result();
        $result->setResources(Collection::make([$file]));

        return $result;
    }