De-Coder
De-Coder

Reputation: 21

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. I dont know where i am going wrong.....i am able to upload image file, pdf file ,documentary file but not mp3. php.in settings didnt work for me...please anybody can guide me. Below is my php code

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>

Upvotes: 0

Views: 1677

Answers (1)

Fernando Torres
Fernando Torres

Reputation: 470

If you are trying to upload an mp3 file, the type of the $_FILES must be

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

not

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

Upvotes: 1

Related Questions