move_uploaded_file():无法移动'/ tmp / php4l8IAc'来上传目录

时间:2018-06-07 13:52:42

标签: php

移动上传文件时出错。我检查了上传路径,看起来是正确的,我也检查了目录权限(755 - 777两者)。

但是我仍然得到这个错误,我的错误是什么?

文件上传器类

public function __construct($file,$mimes = ["jpg","png","jpeg"],$size = null)
    {
     $this->file = $file;
     $this->mimes = $mimes;
     $this->sSize = $size;
     $this->butcher();
    }
private function butcher(){

    $this->realName = pathinfo($this->file->name,PATHINFO_FILENAME);
    $this->size = $this->file->size;
    $this->error = $this->file->error;
    $this->tmpName = $this->file->tmp_name;

    $this->checkErrors();
} // and some control functions...

private function createUniqueName()
{
    $this->newName = $this->realName . "-" . time() . "." . $this->extension;
}

public function upload()
{

    $destination = CONFIG["upload_dir"] . "/" . $this->newName;
    move_uploaded_file($this->tmpName, $destination);
}

和控制器

public function store(RequestInterface $request)
{
    // unqiue name created in construct circle   
    $file = new FileUploader($request->getFile("image"));
    // then upload the file
    $file->upload();
...

并上传dir(在配置文件中)

'upload_dir' => PUBLIC_PATH."/uploads"

和常量

define("PUBLIC_PATH",BASE_PATH."/public");
define ('BASE_PATH', realpath(dirname(__FILE__)));

的var_dump(CONFIG [ “upload_dir”]);

/var/www/cms/public/uploads

那么......有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我不确定为什么,但是当我在app目录上给予755权限时,它就开始工作了。

有趣的是,我提供了755个权限uploads文件夹,但它没有用。