简体   繁体   English

无法上传mp3文件

[英]Unable to upload mp3 file

I have already change php.in config where have set max_size = 256M but it still does not allow me to upload. 我已经更改了php.in config,其中已设置max_size = 256M,但仍然不允许我上传。 I dont know where i am going wrong.....i am able to upload image file, pdf file ,documentary file but not mp3. 我不知道我要去哪里错了.....我能够上传图像文件,pdf文件,文档文件,但不能上传mp3。 php.in settings didnt work for me...please anybody can guide me. php.in设置对我不起作用...请任何人都可以指导我。 Below is my php code 下面是我的PHP代码

Thanks in advance! 提前致谢!

<?php
    //Concept of file upload
    if(isset($_POST['submit']))
    {

     $file = $_FILES['files']['name'];
     $type = $_FILES['files']['type'];
     $file_tmp = $_FILES['files']['tmp_name'];
     $size = $_FILES['files']['size'];
     $file_err = $_FILES['files']['error'];
    if($size!=null)
    {

        if($_FILES['files']['size'] <= 10000000   && $_FILES['files']['type'] == "audio/mpeg")
        {
     $path = "D:/";
     $path = $path.basename($file);

        if(!is_uploaded_file($file))
        {
        $flag = move_uploaded_file($file_tmp, $path);
        if($flag == true)
        {
            echo "Moved Success";
        }
        else
        {
            echo "Some problem";
        }
        }
        else
        {
            echo "Already Uploaded";
        }
      }
      else
      {
         echo "Not audio file";
      } 
    }
    else if($size > 10000000)
    {
        echo "Size exceeded";
    }

    else if($size == null)
    {
       echo "Please select a file";
    }
    else
    {
        echo "Error".$file_err;
    }

    }
    ?>
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    <form action="basic.php" method="post" enctype="multipart/form-data">
    <input type="file" name="files"/>
    <input type="submit" value="upload" name="submit"/>
    </form>
    </body>
    </html>

If you are trying to upload an mp3 file, the type of the $_FILES must be 如果您要上传mp3文件,则$ _FILES的类型必须为

&& $_FILES["file"]["type"] == "audio/mp3"

not

&& $_FILES['files']['type'] == "audio/mpeg"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM