上传附件(图片/音频/视频)
@param string $filepath 本地文件地址
@param int $type 文件类型: 2:图片 3:音频 4:视频
774435
public function uploadFile($filepath,$type=2) {
		$send_snoopy = new Snoopy;
		$send_snoopy->referer = "http://mp.weixin.qq.com/cgi-bin/indexpage?t=wxm-upload&lang=zh_CN&type=2&formId=1";
		$t = time().strval(mt_rand(100,999));
		$post = array('formId'=>'');
		$postfile = array('uploadfile'=>$filepath);
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$send_snoopy->set_submit_multipart();
		$submit = "http://mp.weixin.qq.com/cgi-bin/uploadmaterial?cgi=uploadmaterial&type=$type&token=".$this->_token."&t=iframe-uploadfile&lang=zh_CN&formId=	file_from_".$t;
		$send_snoopy->submit($submit,$post,$postfile);
		$tmp = $send_snoopy->results;
		$this->log('upload:'.$tmp);
		preg_match("/formId,.*?\'(\d+)\'/",$tmp,$matches);
		if (isset($matches[1])) {
			return $matches[1];
		}
		return false;
	}
2870
public function replaceTypeHintsInFile(
        string $filePath,
        string $type,
        string $dbalType,
        bool $isNullable
    ): void {
        $contents = \ts\file_get_contents($filePath);

        $search = [
            ': string;',
            '(string $',
            ': string {',
            '@var string',
            '@return string',
            '@param string',

        ];

        $replaceNormal   = [
            ": $type;",
            "($type $",
            ": $type {",
            "@var $type",
            "@return $type",
            "@param $type",
        ];
        $replaceNullable = [
            ": ?$type;",
            "(?$type $",
            ": ?$type {",
            "@var $type|null",
            "@return $type|null",
            "@param $type|null",
        ];
        $replaceRemove   = [
            ';',
            '($',
            ' {',
            '',
            '',
            '',
        ];

        $replace = $replaceNormal;

        if (\in_array($dbalType, MappingHelper::MIXED_TYPES, true)) {
            $replace = $replaceRemove;
        } elseif ($isNullable) {
            $replace = $replaceNullable;
        }

        $contents = \str_replace(
            $search,
            $replace,
            $contents
        );

        \file_put_contents($filePath, $contents);
    }
269014
public function serveFile($filePath, $mimeType) {
		// if the file exists at the specified path
		if (\file_exists($filePath) && \is_file($filePath)) {
			\header('Content-Type: ' . $mimeType, true);
			\header('Accept-Ranges: none', true);
			\header('Connection: close', true);

			// pipe the actual file contents through PHP
			\readfile($filePath);
		}
		// if the file could not be found
		else {
			throw new \RuntimeException('File `' . $filePath . '` not found');
		}
	}
674671
public static function detectStrict(string $filePath, string $type = null): string
    {
        $type = static::detect($filePath, $type);

        if (!$type) {
            throw new NoTypeDetectedException();
        }

        return $type;
    }
102457
public function importScript(string $filepath, string $type = 'text/javascript', bool $cacheBust = false): bool
    {
        if(!is_file($filepath)) {
            trigger_error('file "'.$filepath.'" failed for import, ressource not found or not a file', E_USER_NOTICE);

            return false;
        }
        if(!is_readable($filepath)) {
            trigger_error('file "'.$filepath.'" failed for import, ressource is not readable', E_USER_NOTICE);

            return false;
        }

        if($cacheBust)
            $filepath = self::cacheBust($filepath);
        $this->addScript(self::_getIncludeContents($filepath), $type);

        return true;
    }
917100
public function uploadMedia($filePath, $mediaType)
    {
        $result = $this->httpPost(self::WECHAT_MEDIA_UPLOAD_URL .
            'access_token=' . $this->getAccessToken() . '&type=' . $mediaType, [
                // php 5.5将抛弃@写法,引用CURLFile类来实现 @see http://segmentfault.com/a/1190000000725185
                'media' => class_exists('\CURLFile') ? new \CURLFile($filePath) : '@' . $filePath
            ]);
        return isset($result['media_id']) ? $result : false;
    }
221182
public static function writeFile($filename, $content, $type = 1)
    {
        if ($type == 1) {
            is_file($filename) && self::delFile($filename); //删除文件
            self::createFile($filename);
            self::writeFile($filename, $content, 2);
            return true;
        } else {
            if (!is_writable($filename)) return false;
            $handle = fopen($filename, 'a');
            if (!$handle) return false;
            $result = fwrite($handle, $content);
            if (!$result) return false;
            fclose($handle);
            return true;
        }
    }
426204
public function loadFile($filePath)
    {
        if (strrpos($filePath, $this->extension) !== false) {
            $fileKey = str_replace([$this->path, $this->extension, DIRECTORY_SEPARATOR], ['', '', '-'], $filePath);
            $this->store(camelcase($fileKey), new SplFileInfo($filePath));
        }
    }
244976
public function setFile($filePath = '.gitignore')
    {
        $this->fileContent = array();
        $this->afterLine = null;
        $this->filePath = $filePath;
        $this->checkPermissions();
        $this->parse();
    }
500300
public function pasteFile($type)
    {
        $this->event(YouweFileManagerEvents::BEFORE_FILE_PASTED);
        $this->resolveImage();
        $this->getDriver()->pasteFile($this->getCurrentFile(), $type);
        $this->event(YouweFileManagerEvents::AFTER_FILE_PASTED);
    }
603095
protected function interfacePostCopy(
        string $filePath
    ): void {
        $this->findAndReplaceHelper->replaceFieldInterfaceNamespace($this->interfaceNamespace, $filePath);
        $this->replaceDefaultValueInInterface($filePath);
        $this->postCopy($filePath);
    }
1161173
public static function bindings(string $filePath = null)
    {
        if (is_file($filePath)) {
            /** @noinspection PhpIncludeInspection */
            $bindings = require_once $filePath;

            $bindings = is_array($bindings) ? $bindings : [];

            IOC::addBindings($bindings);

            Event::dispatch('minimal.loaded.bindings', [$filePath, $bindings]);
        }
    }
775291
public function setFilePath( $filePath )
	{
		$this->filePath      = $filePath;
		$this->shortFilePath = str_replace( base_path() , '' , $filePath );

		return $this;
	}
981617
public function createStreamingResponse($filePath, $fileName, $type = 'application/octet-stream')
    {
        $response = new StreamedResponse();
        $this->setStreamCallBack($response, $filePath);
        $this->setStreamHeaders($response, $fileName, $type);

        return $response;
    }
600230
public function checkRootPath($rootpath){
        /* 设置根目录 */
        $this->rootPath = ftp_pwd($this->link) . '/' . ltrim($rootpath, '/');

        if(!@ftp_chdir($this->link, $this->rootPath)){
            $this->error = '上传根目录不存在！';
            return false;
        }
        return true;
    }
252846
function setStoredFile( $file, $path, $type )
    {
        $this->StoredFile = $file;
        $this->StoredPath = $path;
        $this->StoredType = $type;
    }
8467
public function setPath($type, $path)
	{
		if (!array_key_exists($type, $this->paths))
		{
			throw new \Exception(\App::get('language')->txt('Unknown asset path type of %s given.', $type));
		}

		$path = trim((string) $path);

		// Add separators as needed
		$path = DS . trim($path, DS);

		// Add to list of paths
		$this->paths[$type] = $path;

		return $this;
	}