php - Decode base64 image and save it on a webserver - retrieve the same and encode again -


i have image in form of base64 string api response. - saving string directly in database in mediumtext field. seems eating space.

is there way save image flat file - store it's link in image field in database - , retrieve using query again ?

i'm using php on server side - , aws. need i'm running out of db space.

also - know save base64 string decoding image , saving on server - how can retrieve , encode same?

take this, using pair functions base64_encode/base64_decode:

$encoded = 'somebase64encodedstring';  $decoded = base64_decode($encoded); // $decoded binary content of image, save anywhere want. // example: file_put_content('/tmp/image.png', $decoded);  // when want retrieve base64 encoded string again $decoded = file_get_contents('/tmp/image.png'); $encoded = base64_encode($decoded);  // have $encoded, base64 encoded string. please it. 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -