上传文件的主处理方法
@return bool
511802
public function upFile()
    {
        $file = UploadedFile::getInstanceByName($this->fileField);
        $validator = new FileValidator($this->config);
        if ($validator->validate($file, $error)) {
            //设置文件名称
            $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;
            }
        }
        return false;
    }
1020504
public function doUpload()
    {
        // CJ: Create a folder if it doesn't already exist
        if (!file_exists($this->getOption('location'))) {
            mkdir($this->getOption('location'), 0777, true);
        }

        //use the multup library to perform the upload
        $result = Multup::open('file', 'image|max:'.$this->getOption('size_limit') * 1000, $this->getOption('location'),
                                    $this->getOption('naming') === 'random')
            ->sizes($this->getOption('sizes'))
            ->set_length($this->getOption('length'))
            ->upload();

        return $result[0];
    }
161794
public function accept()
    {
        $filename = $this->current()->getRealPath();

        if ('\\' === \DIRECTORY_SEPARATOR) {
            $filename = str_replace('\\', '/', $filename);
        }

        return $this->isAccepted($filename);
    }
421318
public function prepareShutdown()
    {
        if ($this->inShutdown) {
            return false;
        }

        if ($this->errorLogger && $logs = $this->errorLogger->cleanLogs()) {
            $messages = array_map(
                function ($item) {
                    //array($level, $message, $context);
                    $message = $item[1];
                    $context = $item[2];

                    if (isset($context['file'])) {
                        $message .= ' in ' . $context['file'] . ':' . $context['line'];
                    }

                    if (isset($context['stack'])) {
                        foreach ($context['stack'] as $idx => $stack) {
                            $message .= PHP_EOL . sprintf(
                                "#%d: %s%s %s%s",
                                $idx,
                                isset($stack['class']) ? $stack['class'] . '->' : '',
                                $stack['function'],
                                isset($stack['file']) ? 'in' . $stack['file'] : '',
                                isset($stack['line']) ? ':' . $stack['line'] : ''
                            );
                        }
                    }
                    return $message;
                },
                $logs
            );
            error_log(implode(PHP_EOL, $messages));
        }

        $this->inShutdown = true;

        $this->sendCurrentFiles();

        // $this->controller->close() is no longer called here, because it prevented
        // shutdown functions from triggering (see https://github.com/php-pm/php-pm/pull/432)

        if ($this->server) {
            @$this->server->close();
        }

        if ($this->loop) {
            $this->loop->stop();
        }

        return true;
    }
1113037
public function saveChunk()
    {
        $file = $this->request->getFile();

        return $this->_move_uploaded_file($file['tmp_name'], $this->getChunkPath($this->request->getCurrentChunkNumber()));
    }
711698
public function upload()
    {
        $uploaded_files = request()->file('upload');
        $error_bag = [];
        $new_filename = null;

        foreach (is_array($uploaded_files) ? $uploaded_files : [$uploaded_files] as $file) {
            try {
                $new_filename = $this->lfm->upload($file);
            } catch (\Exception $e) {
                Log::error($e->getMessage(), [
                    'file' => $e->getFile(),
                    'line' => $e->getLine(),
                    'trace' => $e->getTraceAsString()
                ]);
                array_push($error_bag, $e->getMessage());
            }
        }

        if (is_array($uploaded_files)) {
            $response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
        } else { // upload via ckeditor 'Upload' tab
            if (is_null($new_filename)) {
                $response = $error_bag[0];
            } else {
                $response = view(Lfm::PACKAGE_NAME . '::use')
                    ->withFile($this->lfm->setName($new_filename)->url());
            }
        }

        return $response;
    }
1355599
public function safeUp()
    {
        $this->db->createCommand()
            ->insert('dp_admin_menu_url', [
                'name' => '菜单拖拽排序',
                'alias' => 'admin.menu.drop',
                'route' => '/admin/menu/drop',
                'host' => '',
                'note' => '',
                'method' => 'POST',
                'status' => 1,
            ])
            ->execute();

        $this->db->createCommand()
            ->insert('dp_admin_menu_url_relation', [
                'menu_id' => 5,
                'url_id' => $this->db->lastInsertID,
                'status' => 1,
            ])
            ->execute();
    }
925181
public function upload()
    {
        if (!$this->validate()) {
            return false;
        }

        try {
            $save_path = Yii::getAlias($this->_uploadDir);
            FileHelper::createDirectory($save_path);

            $image = $this->image->baseName . '.' . $this->image->extension;

            if (!$this->image->saveAs(FileHelper::normalizePath($save_path . '/' . $image))) {
                return false;
            }

            $this->path = Yii::getAlias($save_path . '/' . $image);
            $this->url = Yii::getAlias($this->_viewPath . '/' . $image);

            return true;

        } catch (Exception $e) {
            Yii::error($e->getMessage());
        }

        return false;
    }
1099162
public function stream_flush()
    {
        if ( ! $this->needsFlush) {
            return true;
        }

        $this->needsFlush = false;
        $this->bytesWritten = 0;

        // Calling putStream() will rewind our handle. flush() shouldn't change
        // the position of the file.
        $pos = ftell($this->handle);

        $args = [$this->getTarget(), $this->handle];
        $success = $this->invoke($this->getFilesystem(), 'putStream', $args, 'fflush');

        if (is_resource($this->handle)) {
            fseek($this->handle, $pos);
        }

        return $success;
    }
170334
public function accept()
    {
        $fileinfo = $this->current();
        if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
            return false;
        } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
            return false;
        }

        return true;
    }
407026
private function _multipart()
    {
        $files = $this->_request->getFiles()->toArray();
        if (!isset($files['file']) || empty($files['file'])) {
            $this->_setError(PLUPLOAD_INPUT_ERR);
            return false;
        }
        $file = reset($files['file']);
        /* @var $file \Mmi\Http\RequestFile */
        if (reset($file)->tmpName && is_uploaded_file(reset($file)->tmpName)) {
            if (!$this->_readWrite(reset($file)->tmpName, true)) {
                return false;
            }
        } else {
            $this->_setError(PLUPLOAD_INPUT_ERR);
            return false;
        }
        return true;
    }
1347689
public function accept()
	{
		if( $this->getInnerIterator()->isDot() )
			return FALSE;

		$isDir	= $this->getInnerIterator()->isDir();
		if( !$this->showFiles && !$isDir )
			return FALSE;

		if( $this->stripDotEntries )															//  skip all folders and files starting with a dot
		{
			if( substr( $this->getFilename(), 0, 1 ) == "." )									//  found file or folder is hidden
				return FALSE;
			
			if( substr( $this->getSubPathname(), 0, 1 ) == "." )								//  inner path is hidden
				return FALSE;

			$subPath	= str_replace( "\\", "/", $this->getSubPathname() );					//  be nice to Windows
			if( preg_match( '/\/\.\w/', $subPath ) )											//  atleast 1 folder in inner path is hidden
				return FALSE;
		}
		return TRUE;
	}
1296949
public function flush()
    {

        $files = $this->getFileSystem()->files($this->getFolder());
        foreach($files as $file)
        {
            $this->delete($file);
        }

        return true;
    }
924911
protected function validateFileUpload()
    {
        if ($this->isError()) {
            return null;
        }

        $submitted_files = $this->getSubmitted('files');

        /* @var $file \SplFileInfo */
        $file = reset($submitted_files);
        $request_files = $this->request->file('files');

        if (empty($request_files['name'][0])) {
            $this->setErrorRequired('files', $this->translation->text('Files'));
            return false;
        }

        $result = $this->file_transfer->uploadMultiple($request_files, false, $file->getRealPath());
        $this->setSubmitted('uploaded', $result);
        return true;
    }
1005550
public function flush()
    {
        if (false !== $many = $this->put($this->_stringBuffer, FILE_APPEND)) {
            $this->_stringBuffer = "";
            return $many;
        }
        throw new Exception("文件写入失败+", 100100302);
    }
1281021
public function update()
        {
                $ok = true;

                // perform updates...
                $ok = $this->updateFile(self::FILENAME_RULES);

                if ($ok)
                        $ok = $this->updateFile(self::FILENAME_CONVERTER);

                return $ok;
        }
897421
public function accept()
    {
        $filename = $this->current()->getRelativePathname();

        if ('\\' === \DIRECTORY_SEPARATOR) {
            $filename = str_replace('\\', '/', $filename);
        }

        return $this->isAccepted($filename);
    }