搜尋

首頁  >  問答  >  主體

在tp3.2中使用upload類別自訂子目錄產生方法

private function savefiles($files,$student_id){
    $config=[
        'rootPath'      =>  WORKING_PATH.FILES_UPLOAD_PATH, //保存根路径
        'subName'       => array('creatSubName',$student_id),
    ];
    $upload = new Upload($config);
    $upload-> subName = array('creatSubName',$student_id);
    $uploadres = $upload->uploadOne($files);
    if ($uploadres){
        return $uploadres;
    }else{
        return false;
    }
}

public function creatSubName($student_id){
    dump("创建名字!");die;
    return $student_id;
}

這樣寫不進入creatSubName方法,不傳入參數也是一樣,求指教

桃子桃子2211 天前985

全部回覆(2)我來回復

  • 桃子

    桃子2019-02-25 17:18:35

    目前暫時使用的upload 裡面的savepath屬性進行替代,能夠達成效果

    private function savefiles($files,$student_id){
        $config=[
            'rootPath'      =>  WORKING_PATH.FILES_UPLOAD_PATH, //保存根路径
            'autoSub'       =>  false, //自动子目录保存文件
            'savePath'       => $student_id.'/'.date('Y-m-d').'/',
        ];
        $upload = new Upload($config);
        $uploadres = $upload->uploadOne($files);
        if ($uploadres){
            return $uploadres;
        }else{
            return false;
        }
    }


    回覆
    0
  • 取消回覆