php base64上傳圖片

                     $ymd = date("Ymdhis");
        //圖片路徑地址
        $img = str_replace('data:image/png;base64,', '', $img);
        $img = str_replace(' ', '+', $img);
        $data = base64_decode($img);

        $imgPath='./upload/person/'.$ymd.'jpg';
        $fp=fopen($imgPath,'w');
        fwrite($fp,$data);
        fclose($fp);
        $ary['status'] = 1;
        $ary['info'] = '保存圖片成功';
        $ary['url'] = $imgPath;

        return $ary;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章