如何将base64字符串转换为音频mp3文件? [英] How to convert base64 string into an audio mp3 file?

查看:450
本文介绍了如何将base64字符串转换为音频mp3文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从android端获取了base64字符串.我必须将其转换为音频文件,并将其保存到文件夹中.我以为我必须先将其转换为字节数组.然后,在它之后,我必须将其转换为mp3文件.但是不知道如何.我已经完成了base64到图像的工作.如果有人知道答案,请举例说明.谢谢.

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.

推荐答案

如果base64编码的数据已经表示一个MP3文件,则应该与对base64数据进行解码并将其存储在文件中一样简单:

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));

这篇关于如何将base64字符串转换为音频mp3文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆