PHP code: Do not download .wav

0

I have the following problem, I am creating a code in PHP that I downloaded the audios of an external disk, I can already access the disk but at the moment of downloading it does not play audio to me. He only shows me the weight and everything but he does not reproduce me.

In what I will be failing, I have already investigated and nothing that I give with the joke !!

I enclose the code and thank you for your help,

    <?php

if (!isset($_GET['file']) || empty($_GET['file'])) {
 exit();
}
$file = basename($_GET['file']);
///$recordd = basename($_GET['file']);;
$con = mysqli_connect("localhost","root","","grabaciones");
$consulta = "SELECT 'fecha' FROM 'grabaciones' WHERE 'record' LIKE '$file'";
$resultado = mysqli_query($con , $consulta);
while($misdatos = mysqli_fetch_assoc($resultado)){
$lol = str_replace('-', '', $misdatos["fecha"]);
$root = "E://GNP/NOVIEMBRE/$lol/";
$path = $root.$file;
$type = 'audio/x-wav';
echo $path;
if (is_file($path)) {
 $size = filesize($path);
 if (function_exists('mime_content_type')) {
 $type = mime_content_type($path);
 } else if (function_exists('finfo_file')) {
 $info = finfo_open(FILEINFO_MIME);
 $type = finfo_file($info, $path);
 finfo_close($info);
 }
 if ($type == '') {
 $type = "application/force-download";
 }
 // Define los headers
 header("Content-Type: $type");
 header("Content-Disposition: attachment; filename=$file");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: " . $size);
 // Descargar el archivo
 readfile($path);
} else {
 die("El archivo no existe.");
}
}?>
    
asked by angel ramirez 20.11.2018 в 21:00
source

0 answers