移动音频上传返回八位字节/流

时间:2019-11-19 15:01:59

标签: php audio upload mime-types

在台式机上,上传正常进行,但是当我尝试从移动设备上载时,它说扩展名在数组之外,并且打印返回八位字节流,有什么想法吗?我看不出有什么问题。我尝试了许多音频扩展,检查了MIME并在一些智能手机上进行了测试,但没有成功。

if (isset($_POST['submit_atrack'])) {
$fileinfo=PATHINFO($_FILES["audio"]["name"]);
$newFilename=$fileinfo['filename'] . uniqid($usr_idLogged) . "." . $fileinfo['extension'];
move_uploaded_file($_FILES["audio"]["tmp_name"],"atracks/" . $newFilename);
$location = 'atracks/' . $newFilename;

$formatos = array('audio/mpeg', 'audio/ogg', 'audio/mp3', 'audio/*', 'audio/wav');
$tamanho_max    = 500000000; //500 mb


    if (empty($_FILES['audio']['name']))
    {
        $upload_empty = urlencode("empty");
        header("Location:playlist?newtrack=".$upload_empty . "&playlist=" . $selectedPlaylist);
        exit;
    }
    else if (!in_array($_FILES['audio']['type'], $formatos))
    {
        $upload_incorrectformat = urlencode("incorrectext");
        header("Location:playlist?newtrack=".$upload_incorrectformat . "&playlist=" . $selectedPlaylist);
        exit;
    }
    else if (in_array($_FILES['audio']['type'], $formatos)) 
    {
        if($_FILES['audio']['size'] >= $tamanho_max)
        {
            $upload_maxsize = urlencode("maxsizereached");
            header("Location:playlist?newtrack=".$upload_maxsize . "&playlist=" . $selectedPlaylist);
            exit;
        }
        else 
        {
            $atitle = mysqli_real_escape_string($connection, $_POST['atitle']);
            $atag = mysqli_real_escape_string($connection, $_POST['atag']);
            $atagcolor = mysqli_real_escape_string($connection, $_POST['atagcolor']);
            mysqli_query($connection,"INSERT INTO tbl_users_atrack (atrack_title, atrack_path, atrack_tag, atrack_tagColor, atrack_playlistId) VALUES ('$atitle', '$location', '$atag', '$atagcolor', '$selectedPlaylist')");
            $upload_success = urlencode("success");
            header("Location:playlist?newtrack=" . $upload_success . "&playlist=" . $selectedPlaylist);
            exit;
        }
    }
}

0 个答案:

没有答案