You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
error_reporting(-1);
|
|
|
|
ini_set("display_errors", "On");
|
|
|
|
// requires php5
|
|
|
|
define('UPLOAD_DIR', '../uploads/4/');
|
|
|
|
$img = $_POST['base64'];
|
|
|
|
$img = str_replace('data:audio/mp3;base64,', '', $img);
|
|
|
|
$img = str_replace(' ', '+', $img);
|
|
|
|
$data = base64_decode($img);
|
|
|
|
$file = UPLOAD_DIR . uniqid() . '.mp3';
|
|
|
|
$success = file_put_contents($file, $data);
|
|
|
|
|
|
|
|
# make a database of recordings
|
|
|
|
$item=array('name'=>$_POST['name'],'date'=>date("d/m/Y"), 'file'=>$file);
|
|
|
|
$handle=fopen('../uploads/4/index.jsons','a');
|
|
|
|
fwrite($handle,json_encode($item)."\n");
|
|
|
|
fclose($handle);
|
|
|
|
print $success ? $file : 'Unable to save the file.';
|
|
|
|
?>
|