Tp5 uploads pictures to the picture server

due to the problem of the company"s project, there are a lot of visits. I want to build a picture server and ask how to modify the existing method of saving img to submit img and save it to the picture server.

related codes

private function _ uploadImg () {

    $img = "";
    if(isset($_FILES["img"]) && !empty($_FILES["img"]["name"])){
        $file = request()->file("img");
        // /public/uploads/ 
        $path = config("uploads_path").$this->controller_name."/";
        $info = $file->move(ROOT_PATH.$path);
        if($info){
            $img = "/uploads/".$this->controller_name."/".str_replace("\\","/",$info->getSaveName());
        }else{
            // 
            request()->isAjax() ? $this->ajaxReturn(0,$file->getError()) : $this->error($file->getError());
        }
    }
    return $img;
}

Apr.08,2021
Menu