无法打开流:Windows上的参数无效

时间:2015-02-23 13:22:44

标签: php windows

保存文件时发生以下错误。

file_put_contents(C:\ XAMPP \ htdocs中\ EntisServer \数据\文件\ 0762717314e01b7dc526ae5214b6a213dbbd1573.jpg ):无法打开流:无效参数

我似乎无法找出无效参数的含义。一个问题可能是我使用两个非转义反斜杠的目录名称。所以,我添加了转义反斜杠。不过,没有运气。我认为重要的是要注意此代码在Windows机器上运行。

        $filename = sha1(uniqid(mt_rand(), true));
        $this->path = $filename . '.' . $extension;

        $raw = base64_decode($base64);

                    if(file_put_contents('C:\\xampp\\htdocs\\EntisServer\\data\\documents\\'.$this->path, $raw)===false){
            throw new \Exception('Cannot write file: '.$this->getUploadRootDir().'/'.$this->path);
        }

注1:也可能很重要,代码是使用PHPUnit从Netbeans运行的

注2 :当从外部源(不是phpunit)调用Web服务时,代码是Web服务的一部分,文件将被保存。有任何想法吗?

0 个答案:

没有答案
相关问题