1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

image uploads but mp3 won't

Discussion in 'PHP & Perl' started by Mutikasa, Dec 3, 2011.

  1. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    575
    Likes Received:
    212
    Hi to all,
    this is my <form>

    HTML:
    <form action="upload.php"
    enctype="multipart/form-data" method="post">
    <p>
    Please select image<br>
    <input type="file" name="image" size="40">
    </p>
    <p>
    Please select audio<br>
    <input type="file" name="audio" size="40">
    </p>

    and this is my upload.php
    PHP:
    // checking image
    if (($_FILES["image"]["type"] == "image/gif")
    or (
    $_FILES["image"]["type"] == "image/jpeg")
    or (
    $_FILES["image"]["type"] == "image/pjpeg")
    or (
    $_FILES["image"]["type"] == "image/png"))
    {
        if (
    $_FILES["image"]["error"] == 0)
        {
            
    move_uploaded_file($_FILES["image"]["tmp_name"], 
            
    "upload/".$_FILES["image"]["name"]);
            
        }
        else
        {
            echo 
    "image upload failed";
        }
    }
    else
    {
        echo 
    "file is not supported image";
        
    }
        
    // checking mp3
    if (substr($_FILES["audio"]["name"],-3) == "mp3")
    {
        if (
    $_FILES["audio"]["error"] == 0)
        {
            
    move_uploaded_file($_FILES["audio"]["tmp_name"], 
            
    "upload/".$_FILES["audio"]["name"]);
        }
        else
        {
            echo 
    "audio upload failed";
        }
    }
    else
    {
        echo 
    "file is not supported audio";
        
    }
    now, image get's uploaded and moved to ./upload but on mp3 it echoes "audio upload failed".
    Don't get it, tnx for help
     
  2. xpwizard

    xpwizard Junior Member

    Joined:
    Nov 6, 2010
    Messages:
    198
    Likes Received:
    122
    Try this... (Don't know if it will work).

    Code:
    Old;
    if ($_FILES["audio"]["error"] == 0)
    
    New:
    if ($_FILES["audio"]["error"] === false)
     
    • Thanks Thanks x 1
  3. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    575
    Likes Received:
    212
    it didn't work, but thanks for help
     
  4. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    575
    Likes Received:
    212
    this is solved. maximum upload filesize was set only to 2M