<form enctype="multipart/form-data" action="" method="POST">
Отправить этот файл: <input name="userfile" type="file" />
<input type="submit" value="Отправить файл" />
</form>
<?php
$uploaddir = 'test/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "Файл корректен и был успешно загружен.\n".$uploadfile;
echo "<br>";
}
$counter = 0;
foreach (glob("{$uploaddir}*.mp3*") as $filename) {
$counter++;
$myAudio = "myAudio".$counter;
echo "<audio id=\"$myAudio\">";
echo "<source src=\"$filename\" type=\"audio/mpeg\">";
echo "</audio>";
echo "<br>";
echo $counter."  ";
echo "<button onclick=\"play$myAudio()\" type=\"button\">Play Audio</button>";
echo "<button onclick=\"pause$myAudio()\" type=\"button\">Pause Audio</button>";
}
$counter = 0;
foreach (glob("{$uploaddir}*.mp3*") as $filename) {
$counter++;
$myAudio = "myAudio".$counter;
echo "<script>";
echo "function play$myAudio() { ";
echo "var x = document.getElementById(\"$myAudio\");";
echo "x.play();";
echo "}";
echo "function pause$myAudio() {";
echo "var x = document.getElementById(\"$myAudio\");";
echo "x.pause();";
echo "}";
echo "</script>";
}
?>
|