move upload file

@param $file
@param \Illuminate\Database\Eloquent\Model $model
@return string
515017
public function moveFile($file, $model)
    {
        $path = $this->getUploadPath($model, $this->options);
        $this->makeDirectoryBeforeUpload($path, true);

        if ( ! is_null($this->elfinderFilePath) ) {
            $this->copy($this->elfinderFilePath, $path . '/' . $this->fileName);
        } else {
            $this->move($file, $path . '/' . $this->fileName);
        }

        return [
            'fileName'  => $this->fileName,
            'fileSize'  => $this->fileSize
        ];
    }
267540
public function move(FileUpload $file) : ?string
    {
        if ($file->isOk())
        {
            $this->privateFileName = (new DateTime())->getTimestamp() . '-' . $file->getSanitizedName();

            $length = strlen($this->privateFileName);

            if ($length > self::MAX_FILE_NAME_LENGTH)
            {
                $maxLength = self::MAX_FILE_NAME_LENGTH;

                throw new ProtectedFileException("Maximal length of file name is '{$maxLength}' chars. File name: '{$file->getSanitizedName()}' have {$length} chars.");
            }

            $privateFilePath = self::PRIVATE_ABSOLUTE_PATH . $this->destination . $this->privateFileName;

            if (file_exists($privateFilePath))
            {
                throw new ProtectedFileException("File '{$this->privateFileName}' already exists. Maybe anyone upload same file at same time.");
            }

            FileSystem::createDir(self::PRIVATE_ABSOLUTE_PATH . $this->destination);
            $file->move($privateFilePath);
        }

        return $this->privateFileName;
    }
392111
public function upload($model, $request)
    {
        $files = $this->getFile($request);

        if (array_search(null,$files) === false) {
            foreach($files as $key => $file) {
                $this->setFileName($file);
                $this->setFileSize($file);
                $this->files[] = $this->moveImage($file, $key, $model, $request);
            }
            return count($this->files) === 1 ? $this->files[0] : $this->files;
        }
        return false;
    }
1249194
public function getFile($file) {
		$timeStamp = microtime(true);
		if($file instanceof BundleEntity\File){
			return new ModelResponse($file, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, microtime(true));
		}
		$result = null;
		switch($file){
			case is_numeric($file):
				$result = $this->em->getRepository($this->entity['f']['name'])->findOneBy(array('id' => $file));
				break;
			case is_string($file):
				$result = $this->em->getRepository($this->entity['f']['name'])->findOneBy(array('url_key' => $file));
				if(is_null($result)){
					$result = $this->em->getRepository($this->entity['f']['name'])->findOneBy(array('source_original' => $file));
					if(is_null($result)){
						$result = $this->em->getRepository($this->entity['f']['name'])->findOneBy(array('source_preview' => $file));
					}
				}
				break;
		}
		if(is_null($result)){
			return new ModelResponse($result, 0, 0, null, true, 'E:D:002', 'Unable to find request entry in database.', $timeStamp, microtime(true));
		}

		return new ModelResponse($result, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, microtime(true));
	}
490473
public function upload($file, $to = null)
    {
        if ($this->test($file)) {
            if (null === $to) {
                $to = $file['name'];
            }
            if (!$this->overwrite) {
                $to = $this->checkFilename($to);
            }

            $this->uploadedFile = $to;
            $to = $this->uploadDir . DIRECTORY_SEPARATOR . $to;

            // Move the uploaded file, creating a file object with it.
            if (move_uploaded_file($file['tmp_name'], $to)) {
                return $this->uploadedFile;
            } else {
                $this->error = self::UPLOAD_ERR_UNEXPECTED;
                return false;
            }
        } else {
            return false;
        }

    }
235540
public function moveAfter($model)
    {
        if ( ! $model ) {
            $this->moveFirst();
            return;
        }
        if ( is_numeric($model) ) {
            $model = call_user_func("$this->ownerClassName::findOne", $model);
        }
        $parentId = $this->parentIdField ? $model->{$this->parentIdField} : 0;
        if ( $model->{$this->sortField} == $this->defaultSortVal ) {
            $this->reorder($parentId);
            $model->refresh();
        }
        $nextIdx = $this->getMinIdx($parentId, $model->{$this->sortField});
        if ( $nextIdx - $model->{$this->sortField} < 2 ) {
            $this->reorder($parentId);
            $model->refresh();
            $nextIdx = $this->getMinIdx($parentId, $model->{$this->sortField});
        }
        $newIdx = $model->{$this->sortField} + floor(($nextIdx - $model->{$this->sortField})/2);
        if ( $this->parentIdField ) {
            call_user_func("$this->ownerClassName::updateAll", [
                $this->sortField => $newIdx,
                $this->parentIdField => $parentId,
            ], [ $this->primaryKey => $this->owner->primaryKey ]);
        } else {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => $newIdx ],
                [ $this->primaryKey => $this->owner->primaryKey ]);
        }
        $this->invalidateTagDependency();
    }
398723
public function move()
    {
        // do any actions if files exists

        foreach ($this->files as $n => $file) {

            $filename = $file->getName();

            if (isset($this->rules['hash']) === true) {
                if (empty($this->rules['hash']) === true) {
                    $this->rules['hash'] = 'md5';
                }

                if (!is_string($this->rules['hash']) === true) {
                    $filename = call_user_func($this->rules['hash']) . '.' . $file->getExtension();
                } else {
                    $filename = $this->rules['hash']($filename) . '.' . $file->getExtension();
                }
            }

            if (isset($this->rules['sanitize']) === true) {
                $filename = Format::toLatin($filename, '', true);
            }

            if (isset($this->rules['directory'])) {
                $tmp = rtrim($this->rules['directory'], '/') . DIRECTORY_SEPARATOR . $filename;
            } else {
                $tmp = rtrim($this->rules['dynamic'], '/') . DIRECTORY_SEPARATOR . $filename;

            }

            // move file to target directory
            $isUploaded = $file->moveTo($tmp);

            if ($isUploaded === true) {
                $this->info[] = [
                    'path'      =>  $tmp,
                    'directory' => dirname($tmp),
                    'filename'  => $filename,
                    'size'      => $file->getSize(),
                    'extension' => $file->getExtension(),
                ];
            }
        }

        return $this->getInfo();
    }
97897
protected function addUploadedFile($file)
    {
        $this->clear();

        $this->uploaded_file = $this->getFileManager()->make($file);

        // Get the original values
        $filename = $this->uploaded_file->getClientOriginalName();
        $content_type = $this->uploaded_file->getMimeType();

        // Set model values
        $this->instanceWrite('file_name', $filename);
        $this->instanceWrite('file_size', $this->uploaded_file->getSize());
        $this->instanceWrite('content_type', $content_type);
        $this->instanceWrite('updated_at', date('Y-m-d H:i:s'));
        $this->instanceWrite('queued_file', null);

        // Queue all styles for writing
        $this->setQueue('write', $this->styles);
    }
375194
public function moveFile($file, $path = '')
    {
        $name = token();
        $extension = $file->guessClientExtension();

        $filename = $name . '.' . $extension;
        $imageTmp = Image::make($file->getRealPath());

        if (!$imageTmp) {
            return notify()->error('Oops', 'Something went wrong', 'warning shake animated');
        }

        $path = upload_path_images($path);
        $image = $imageTmp->save($path . $filename);

        return $filename;
    }
829389
public function update( $model, $config = [] ) {

		$attributes = isset( $config[ 'attributes' ] ) ? $config[ 'attributes' ] : [ 'title', 'description', 'caption', 'altText', 'link', 'type', 'content' ];

		if( $model->changed ) {

			// Find existing file
			$existingFile = self::findById( $model->id );

			// Delete from disk
			$existingFile->clearDisk();

			$attributes[] = 'size';
		}

		return parent::update( $model, [
			'attributes' => $attributes
		]);
	}
1064260
public function runMigration($file)
    {
        $migration = $this->getMigrationObjectByFileName($file);

        $this->disableBitrixIblockHelperCache();

        $this->checkTransactionAndRun($migration, function () use ($migration, $file) {
            if ($migration->up() === false) {
                throw new Exception("Migration up from {$file}.php returned false");
            }
        });

        $this->logSuccessfulMigration($file);
    }
1234190
private function generateGalleryImage($model, File $file, $info)
    {
        $image = $this->placeholderImage;

        if ($file->isSvgImage
            || (($file->height <= Config::get('gdMaxImgHeight')) && ($file->width <= Config::get('gdMaxImgWidth')))
        ) {
            $width  = \min($file->width, $this->thumbnailWidth);
            $height = \min($file->height, $this->thumbnailHeight);
            $image  = Image::get($model->path, $width, $height, 'center_center');
        }

        return Image::getHtml(
            $image,
            '',
            'class="gimage removable" title="' . StringUtil::specialchars($info) . '"'
        );
    }
565293
public function hydrate(Entity &$model)
    {
        foreach ($model->getAsserts() as $field => $asserts) {
            if ($this->app['request']->files->has($field)) {
                $file = $this->app['request']->files->get($field);

                if ($file instanceof UploadedFile) {
                    $model->dispatch('upload', [$field, $file]);
                }
            } else {
                $value = trim($this->app['request']->get($field));

                // Detect HTML fields without actual content
                if (empty(strip_tags($value))) {
                    $value = '';
                }

                $model->$field = $value;
            }
        }
    }
1238193
public function move($file) {
        $result = true;
        $this->map(function (FileObject $item) use (&$result, $file) {
            $result = $result && $item->move($file. '/'. $item->getName());
        });
        return $result;
    }
1010463
public function move($toFile)
    {
        if ($this->error == UPLOAD_ERR_OK) {
            return move_uploaded_file($this->tmpName, $toFile);
        } else {
            return false;
        }
    }
1338231
protected function convertFileInformation($file)
    {
        if ($file instanceof UploadedFile) {
            return $file;
        }

        $file = $this->fixPhpFilesArray($file);
        if (\is_array($file)) {
            $keys = array_keys($file);
            sort($keys);

            if ($keys == self::$fileKeys) {
                if (UPLOAD_ERR_NO_FILE == $file['error']) {
                    $file = null;
                } else {
                    $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error']);
                }
            } else {
                $file = array_map([$this, 'convertFileInformation'], $file);
                if (array_keys($keys) === $keys) {
                    $file = array_filter($file);
                }
            }
        }

        return $file;
    }
738235
public function upload($file, $path='')
	{
		$path = ltrim($path, '/');
		$path = rtrim($path, '/');
		$basePath = $this->getImageBasePath();
		$imagePath = $basePath.'/'.$path;

		if (!File::exists($imagePath)) {
			throw new ImageUploaderException("Directory {$path} doesn't exists");
		}

		$uploadedFile = $this->getUploadedFile($file);
		$fileName = $this->generateFileName($uploadedFile->getClientOriginalExtension());
		$uploadedFile->move($imagePath, $fileName);

		if (!is_null($this->temporaryImage)) {
			File::delete($this->temporaryImage);
		}

		return $path.'/'.$fileName;
	}