0

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>
De-Coder
  • 21
  • 11
  • 1
    Possible duplicate of [Which mime type should I use for mp3](http://stackoverflow.com/questions/10688588/which-mime-type-should-i-use-for-mp3) Mime type might depend on your browser. – Tomasz Apr 05 '16 at 13:40
  • than check size `$_FILES['files']['size'] ` – devpro Apr 05 '16 at 13:40
  • I check file size @devpro It is not taking files only...as soon i set submit it's shows no file chosen – De-Coder Apr 05 '16 at 13:47

1 Answers1

1

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"
Fernando Torres
  • 460
  • 7
  • 24
  • In your condition you are validating $_FILES['files']['type'] == "audio/mpeg" But if you really want to know if there is a mp3 uploading yet, you have to validate it. See my changes and change your line of $_FILES['files']['type'] == "audio/mpeg" for $_FILES['files']['type'] == "audio/mp3" – Fernando Torres Apr 05 '16 at 14:20
  • 1
    Please see this post http://stackoverflow.com/questions/22893441/how-to-upload-mp3-files – Fernando Torres Apr 05 '16 at 14:26