0

I would like to know if it is possible to create a audio recording, put the recorded file inside a directory, and transfere this file to a folder, outside the phone, via HTTP.

I built a PHP file that receives the address from the file, and saves it to a folder:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['url']);                                                
$fp = fopen('file_name.3gpp', 'w');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
curl_close ($ch);
fclose($fp);
?>

My Java activity to record audio:

File directory = new File(Environment.getExternalStorageDirectory()
        + File.separator + "record");
directory.mkdirs();

outputFile = Environment.getExternalStorageDirectory() + File.separator
        + "record" + "/record.3gpp";

myRecorder = new MediaRecorder();
myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
myRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
myRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
myRecorder.setOutputFile(outputFile);

Now I would like to get the directory from the recorded audio, and send it using GET.

It would look like this:

http://localhost/folder/record.php?url=DIRECTORY FROM THE AUDIO

How can I do that? Thank you.

Michael Jackson
  • 356
  • 3
  • 18

1 Answers1

0

You cannot send a file to server just like that, you need to post or in other words upload the file as binary. See this stackoverflow question for how to do that:

How do I send a file in Android from a mobile device to server using http?

Community
  • 1
  • 1
muratgu
  • 7,241
  • 3
  • 24
  • 26