Laravel: Save Base64 .png file to public folder from controller

后端 未结 8 1753
灰色年华
灰色年华 2021-02-05 07:46

I send a png image file to controller in base64 via Ajax. I\'ve already test and sure that controller has received id but still can\'t save it to public folder.

8条回答
  •  广开言路
    2021-02-05 07:59

    This is an easy mistake.

    You are using public_path incorrectly. It should be:

    $path = public_path() . "/img/designs/" . $png_url;
    

    Also, I would avoid your method of sending the image. Look at a proper upload in a form and use Laravel's Input::file method.

提交回复
热议问题