执行文件上传

@access  public
@param   string          $name           fileInput's name
@return  boolean                         返回是否上传成功的布尔值
512795
public function upload($name)
        {            
            if(empty($_FILES[$name]['name'])) //上传文件为空时
            {
               $this->message($this->errors['empty']);
                
                return false;
            }
            
            $this->files = $_FILES[$name];
            
            if(!file_exists($this->savePath)) //目录不存在
            {
                $this->message($this->errors['not_exist']);
                
                return false;
            }

            if(!is_writable($this->savePath)) //目录不可写
            {
                $this->message($this->errors['unwritable']);
                
                return false;
            }

            $this->fileExt  = $this->getFileExt($this->files["name"]); //取得扩展名
            
            $this->setSeveName();
            
            return $this->moveFile();
        }
845393
public function resolveFile($name)
    {
        $components = $this->parseResource($name);
        foreach ($components['dirs'] as $dir) {
            if (is_file($file = $dir . ($dir ? '/' : '') .  $components['file'])) {
                return $file;
            }
        }
        return false;
    }
133601
public function isFile(String $name) : Bool
    {
        $file = Method::files($name);

        if( is_array($file) )
        {
            return (bool) $file[0];
        }

        return (bool) Method::files($name);
    }
1158443
function hasUpload($name) {
		// if information about the specified file upload is available
		if (isset($_FILES[$name])) {
			// if the file input had an array-style name
			if (\is_array($_FILES[$name]['error'])) {
				// for any file selected from this input
				foreach ($_FILES[$name]['error'] as $errorCode) {
					if ($errorCode !== \UPLOAD_ERR_NO_FILE) {
						return true;
					}
				}
			}
			// if the file input had a scalar-style name
			else {
				return $_FILES[$name]['error'] !== \UPLOAD_ERR_NO_FILE;
			}
		}

		return false;
	}
185918
public function run($name)
    {
        $fileName = sprintf('%s_%s.sql',
            date('Ymd_His'),
            trim($name)
        );
        $migration = new Migration(null, $fileName);
        $migration->setSql(Migration::TAG_TRANSACTION . PHP_EOL
            . Migration::TAG_UP . PHP_EOL
            . PHP_EOL
            . Migration::TAG_DOWN . PHP_EOL
            . PHP_EOL
        );
        $this->repository->insert($migration);

        return $fileName;
    }
228554
function getFileList($name = NULL){
        if($name ===NULL){
            $ret = array();
            foreach($this->files as $fkey => $fval){
                $ret[$fkey] = $this->getFileList($fkey);
            }
            return $ret ?: FALSE;
        }else{
            if(!isset($this->files[$name])){
                return false;
            }
            return new UploadedFileList($this->files[$name]);
        }
    }
385146
public function delete($name)
    {
        $this->loadModel('Field.FieldInstances');
        $instance = $this->_getInstance($name);

        if ($instance && !empty($this->request->query['file'])) {
            $file = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}", DS);
            $file = new File($file);
            $file->delete();
        }

        $response = '';
        $this->viewBuilder()->layout('ajax');
        $this->title(__d('field', 'Delete File'));
        $this->set(compact('response'));
    }
747608
protected function _mkfile($path, $name) {
		if ($this->tmp) {
			$path = $path.'/'.$name;
			$local = $this->getTempFile();
			$res = touch($local) && ftp_put($this->connect, $path, $local, FTP_ASCII);
			@unlink($local);
			return $res ? $path : false;
		}
		return false;
	}
659474
final public function output(string $name = null)
    {
        $result = implode(static::EOL, $this->registries) . static::EOL
            . static::EOF;

        if ($name === null) {
            return $result;
        }

        Utils::checkOutput(pathinfo($name)['extension'] ?? '');

        header('Content-Type: text/plain');
        header('Content-Length: ' . strlen($result));
        header('Content-Disposition: attachment; filename="' . $name . '"');
        echo $result;
    }
185301
protected function downloadFile($file, $name = null)
    {
        if(file_exists($file) && is_file($file) && is_readable($file)) {
            $mime_type = mime_content_type($file);
            if(in_array($mime_type, ['image/gif', 'image/jpeg', 'image/png'])) {
                $exif_type = exif_imagetype($file);
                $img_ext = image_type_to_extension($exif_type);
                if($img_ext == '.jpeg') {
                    $img_ext = '.jpg';
                }
                switch($exif_type) {
                    case IMAGETYPE_JPEG:
                        $img = imagecreatefromjpeg($file);
                        imagejpeg( $img, NULL, 100 ); 
                        break;
                    case IMAGETYPE_GIF:
                        $img = imagecreatefromgif($file);
                        imagegif( $img ); 
                        break;
                    case IMAGETYPE_PNG:
                        $img = imagecreatefrompng($file);
                        imagepng( $img, NULL, 100 ); 
                        break;
                }
                if(!$img) {
                }
                else {
                    imagedestroy( $img );
                }
                $headers[] = "Content-Type: $mime_type";
                if($name !== null && trim($name) !== '') {
                    //download - without it image will not be downloaded just displayed on broswer
                    if( (strlen($name)-strlen($img_ext)) !== strpos($name, $img_ext) ) {
                        $name .= $img_ext;
                    }
                    $headers[] = "Content-Disposition: attachment; filename=$name";
                }
                self::$instance->app->headers = $headers;
            }
        }
    }
84583
public static function load($name){
		if(substr($name, 0, 7)!='csslib\\') return false;
		
		$filename =  __DIR__.'/src/'.implode('/', array_slice(explode('\\', $name), 1)).'.php';
		
		if(!file_exists($filename)) throw new \Exception('File "'.$filename.'" not found');
		
		require_once $filename;
		
		if(class_exists($name) || interface_exists($name)) return true;
		
		
		throw new \Exception('Class or Interface "'.$name.'" not exists');
	}
320830
public function getFromInput($name = false)
    {
        if ($name) {
            $this->img       = $_FILES[$name];
            $this->handle    = new Upload($this->img);
            $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name);
        }
    }
955668
public static function files($name = null)
    {
        $files = app()->request->getUploadedFiles();

        if (is_null($name)) {
            return $files;
        }

        if (isset($files[$name])) {
            return $files[$name];
        }

        return null;
    }
1336046
public function addInputFile(string $name) : Element\Input\File
    {
        $this->setEnctypeMultipart();

        $input = new Element\Input\File($this, $name);
        $this->addComponent($name, $input);

        return $input;
    }
1354387
private static function getCoroutineContext(string $name)
    {
        $coroutineId = self::getcoroutine();
        if (!isset(self::$coroutineLocal[$coroutineId])) {
            throw new InvalidValueException("协程上下文不存在，coroutineId=".$coroutineId);
        }

        $coroutineContext = self::$coroutineLocal[$coroutineId];
        if (isset($coroutineContext[$name])) {
            return $coroutineContext[$name];
        }
        return null;
    }
77610
public function create($name)
    {
        if (!is_string($name) || strlen($name) >= 30) {
            $this->setError('参数错误,请传入字符串或名字的长度不能大于30字符');

            return false;
        }

        $queryStr = [
            'group' => ['name' => $name],
        ];

        $res = $this->_post('create', $queryStr);

        return $res;
    }
216714
public function move($dir, $name = null)
    {
        if ($this->isValid()) {

            if ($this->test) {
                return parent::move($dir, $name);
            }

            if (is_uploaded_file($this->getPathname())) {

                $target = $this->getTargetFile($dir, $name);

                move_uploaded_file($this->getPathname(), $target);

                chmod($target, 0666 & ~umask());

                return $target;
            }
        }

        throw new \RuntimeException("The file {$this->getPathname()} has not been uploaded via Http");
    }