移动上传的文件():无法移动'/tmp/php4l8IAc&x27;上传目录
移动上载的文件时出错。我检查了上传路径,它似乎是正确的,而且我还检查了目录权限(755-777都是) 但我还是犯了这个错误,我的错误是什么 文件上传器类移动上传的文件():无法移动'/tmp/php4l8IAc&x27;上传目录,php,Php,移动上载的文件时出错。我检查了上传路径,它似乎是正确的,而且我还检查了目录权限(755-777都是) 但我还是犯了这个错误,我的错误是什么 文件上传器类 public function __construct($file,$mimes = ["jpg","png","jpeg"],$size = null) { $this->file = $file; $this->mimes = $mimes; $this->sSize = $size;
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();
...
和上载目录(在配置文件中)
和常数
define("PUBLIC_PATH",BASE_PATH."/public");
define ('BASE_PATH', realpath(dirname(__FILE__)));
变量转储(配置[“上传目录])
所以。。有什么建议吗?我不知道为什么,但当我对应用程序目录授予755权限时,它就开始工作了
有趣的是,我给了755个上传文件夹的权限,但它不起作用。你在哪里设置
$this->newName代码>到某个可用值?服务器是否正在运行SELinux?这也可能会导致权限问题。@RiggsFolly我编辑了我的问题,所以你在哪里调用createUniqueName()
a@BA_Webimax?我还没有安装selinux,我知道它不是ubuntu的默认包
define("PUBLIC_PATH",BASE_PATH."/public");
define ('BASE_PATH', realpath(dirname(__FILE__)));
/var/www/cms/public/uploads