无法使用IOS设备的PHP脚本将音频文​​件上传到服务器

时间:2016-07-26 20:32:58

标签: php ios audio file-upload

我有 PHP 脚本将图像或音频文件上传到服务器

<?php
include "config.php";

function GetImageExtension($imagetype)
 {
   if(empty($imagetype)) return false;
   switch($imagetype)
   {
       case 'image/bmp': return '.bmp';
       case 'image/gif': return '.gif';
       case 'image/jpeg': return '.jpg';
       case 'image/png': return '.png';
       case 'audio/mp3' : return '.mp3';
       case 'audio/mp4' : return '.mp4';
       case 'audio/wav' : return '.wav';
       default: return false;
   }
}

if (!empty($_FILES["uploadedimage"]["name"])) 
{
    $file_name=$_FILES["uploadedimage"]["name"];
    $temp_name=$_FILES["uploadedimage"]["tmp_name"];
    $imgtype=$_FILES["uploadedimage"]["type"];
    $ext= GetImageExtension($imgtype);
    if($ext!=false)
    {
            $imagename=date("d-m-Y")."-".time().$ext;
            $target_path = "img/personal/".$imagename;
        if(move_uploaded_file($temp_name, $target_path))
        {
            $query_upload="INSERT INTO `images_tbl` (`image_id` ,`image_path` ,`subission_date`)
            VALUES (NULL ,  '".$target_path."', CURRENT_TIMESTAMP)";
            mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error()); 
            header("location:room.php");
        }
        else
            {
               exit("Error While uploading image on the server");
            }
    }

}
header("location:room.php");
?>

从Windows操作系统上传文件时效果很好但在上传图像时从IOS(iphone 6手机设备)上传时效果很好但是不允许用户上传音频文件,当用户想上传文件时只是给出了这些选项:图片如下 enter image description here

当用户点击**从文件上传表单中选择文件**时,它会提供仅上传的选项,然后无法上传音频。 我该怎么办呢。 谢谢。

1 个答案:

答案 0 :(得分:0)

我试图找出你的问题,我相信它是因为AAC Protected,Apple Lossless和Audible文件,尝试不同的音频文件,因为有很多。只有少数人受到支持。

下面是受支持的列表:

  • MP3
  • MP4
  • WAV

希望它有所帮助!