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

后端 未结 8 1758
灰色年华
灰色年华 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 08:13

    Actually, Input::all() returns an array of inputs so you have following:

    $data = Input::all();
    

    Now your $data is an array not an object so you are trying to access the image as an object like:

    $data->base64_image
    

    So, it's not working. You should try using:

    $image = $data['base64_image'];
    

    Since it's (base64_image) accessible from $_POST then Input::file('base64_image') won't work because Input::file('base64_image') checks the $_FILES array and it's not there in your case.

提交回复
热议问题