How to save a base64 decoded image in the filesystem using php?

前端 未结 2 850
忘了有多久
忘了有多久 2021-02-04 15:12

I am getting a base64 encoded JPEG string via a POST request to my web service. I want to decode it and save it in the filesystem. How can I achieve this using PHP 5.3. I am

2条回答
  •  悲&欢浪女
    2021-02-04 15:49

    Replacing the blank spaces with + signs is required if the data is derived from canvas.toDataURL() function.

     $encodedString = str_replace(' ','+',$encodedString);
    

    See this question

    It helped a lot in my case.

提交回复
热议问题