Tp5 SplFileObject::__construct(/tmp/phpvuOdFd): failed to open stream: No such file or director解决方法

简介: Tp5 SplFileObject::__construct(/tmp/phpvuOdFd): failed to open stream: No such file or director解决方法

在使用一个后端框架接收3个图片后上传后,3个file文件域,报错:

解决办法:

分别接收文件,最后上传方法(从update往下)

public function update($id)
    {
        $data = input('post.');
        // 接收的数据为空
        $data["pet_src1"]="";
        $data["pet_src2"]="";
        $data["pet_src3"]="";
        if (isset($_FILES['pet_src1']) && $_FILES['pet_src1']['error'] == 0){
$pet_src1 = request()->file('pet_src1');
}
if (isset($_FILES['pet_src2']) && $_FILES['pet_src2']['error'] == 0){
$pet_src2 = request()->file('pet_src2');
}
if (isset($_FILES['pet_src3']) && $_FILES['pet_src3']['error'] == 0){
$pet_src3 = request()->file('pet_src3');
}
if(isset($pet_src1)){
$data['pet_src1'] = $this->upload_file($pet_src1);
}
if(isset($pet_src2)){
$data['pet_src2'] = $this->upload_file($pet_src2);
}
if(isset($pet_src3)){
$data['pet_src3'] = $this->upload_file($pet_src3);
}
        var_dump($data);
    }
   public function upload_file($file){
    // $file = request()->file('image');//这里就不要了
        if($file){
            //将传入的图片移动到框架应用根目录/public/uploads/ 目录下,ROOT_PATH是根目录下,DS是代表斜杠 / 
            $info = $file->move(ROOT_PATH . 'public' . DS .'uploads'. DS );
            if($info){
                  return $info->getSaveName();
            }else{
                // 上传失败获取错误信息
                return $file->getError();
            }
        }
        else{
             die(
        json_encode(
            array(
            'code' => 100,
            'data' => '',
            'msg' => '参数错误或没有图片信息'
        ),480)
);
        }
    }

打印成功解决

相关文章
Flutter之运行提示Could not update files on device: Connection closed before full header was received
Flutter之运行提示Could not update files on device: Connection closed before full header was received
753 0
成功解决:Failed to load resource: net::ERR_FILE_NOT_FOUND
这篇文章提供了解决"Failed to load resource: net::ERR_FILE_NOT_FOUND"错误的步骤,通过修改配置文件中的资源路径设置为相对路径"./"来成功运行打包后的项目。
成功解决:Failed to load resource: net::ERR_FILE_NOT_FOUND
|
前端开发
【前端异常】Module build failed: Error: ENOENT: no such file or directory, scandir ‘G:\OPWeb\public\node_m
【前端异常】Module build failed: Error: ENOENT: no such file or directory, scandir ‘G:\OPWeb\public\node_m
197 0
|
11月前
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
|
安全 关系型数据库 MySQL
xtrabackup 问题“Too many open files”system error number 24
一个MySQL数据库备份的时候出现下面的错误
187 0
|
PyTorch 算法框架/工具
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
215 0
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument