4

I'm getting a base64 string from android side. I have to convert it into an audio file and have to save it into a folder. I thought I have to convert it first into byte array. Then after it, I have to convert it into a mp3 file. But don't know how. I have done work in base64 to image. If anyone know answer then please explain with an example. Thank You.

Akshay Vaghasiya
  • 1,597
  • 9
  • 36
  • 60
  • What data is in the base64 string? Voice or random garbage? If there is a ready-made mp3, say encoded on client side, then process as if it would be a byte sequence, aka base64decode and save to disk. If there's something else, I say make client work instead of doing all this on the server. – Vesper Jun 01 '15 at 11:32

1 Answers1

12

If the base64 encoded data already represents an MP3 file, it should be as easy as decoding the base64 data and storing it in a file:

file_put_contents('audio.mp3', base64_decode($data));
EJTH
  • 2,178
  • 1
  • 20
  • 25