I'm trying to save an audio file on my server. I record the audio on a iPhone in PCM format and send the data encoded as a Base64 string. I have tried 3 different approaches to saving the file, all 3 create an empty wav file:
Attempt 1:
$file = fopen($filePath, 'w');
fwrite($file, base64_decode($this->data['Voicenote']['audio_data']));
fclose($file);
Attempt 2:
file_put_contents($filePath, base64_decode($this->data['Voicenote']['audio_data']));
Attempt 3:
$audioFile = new File($filePath, true);
$audioFile->write(base64_decode($this->data['Voicenote']['audio_data']));
$audioFile->close();