Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi, How to put the FWRecorder.getBase64() string convert wav files in php ? #41

Open
drimk opened this issue Nov 26, 2014 · 2 comments
Open

Comments

@drimk
Copy link

drimk commented Nov 26, 2014

hi friends,
try html form post FWRecorder.getBase64() string

PHP:

  $fileBase64 = str_replace('data:audio/wav;base64,', '',  $_POST['Base64']);
  $decoded = base64_decode($fileBase64 );
  file_put_contents('test.wav', $decoded);

but the test.wav can't play, help ~ thanks very much!

@michalstocki
Copy link
Owner

When we run FWRecorder.getBase64('recordingName'); in Chrome console, it returns proper Data URL string. We can click on it and it plays. It proves that Base64 encoding works correctly. I don't have much experience with PHP so I can't help you without experiments with PHP functions. I need more time for this issue.

@robinsmidsrod
Copy link

@drimk: What does the file(1) command in Unix tell you about the file you've saved (test.wav)? It should say something like RIFF WAVE ..., if it says "data" then you probably don't have a binary clean method of saving the bytes that come out of base64_decode(). If you just try to print out the content of $decoded to your terminal, what does it look like (just need the first few lines, as it it supposed to be binary). You should see the letters RIFF and WAVE somewhere at the start. Also, does str_replace() actually return the modified string, instead of modifying the input string?

PS: Not a PHP programmer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants