简体   繁体   中英

Upload MP3 file via php

I have a problem with uploading a mp3 file via my php website. It allows me to you load everything under 2MB but nothing over. It has worked previously

The hosting provider has increased the fastcgi timeout limit also .htaccess file within your Domain directory and added the following: php_value max_execution_time 300,

We have also increased the fastcgi timeout limit and added a .htaccess file: php_value upload_max_filesize 20M php_value post_max_size 20M

the site come back saying filetype not supported.

Please see some of the following code. Thanks in advance for any help.

//ende wenn audio gelàscht werden soll
// audio wird hochgeladen
if($_GET["add"] == "audio"){

    if (empty($_POST["audioRelease"])) {
        header("Location: ../media.php?uperror=Please upload a Showcase in My Showcase page first!");
        die();
    }

    // var die gesetzt werden
    //check ob mit upload file die grenze erreicht ist
    $sqlArtist = "SELECT *";
    $sqlArtist .= " FROM zap_artist INNER JOIN zap_user ON zap_artist.userID = zap_user.userID ";
    $sqlArtist .= " WHERE ";
    $sqlArtist .= " zap_artist.userID = " . $_SESSION["userID"];
    $rsArtist = mysql_query($sqlArtist);
    $crArtist = mysql_fetch_assoc($rsArtist);
    $account = $crArtist["account"];

    if ($account == 1){
        $mySpace = "0";
    }else
    if ($account == 2){
        $mySpace = "20";
    }else
    if ($account == 3){
        $mySpace = "40";
    }else
    if ($account == 5){
        $mySpace = "10";
    }else
    if ($account == 6){
        $mySpace = "40";
    }else
    if ($account == 7){
        $mySpace = "80";
    }

    //errechne wieviel platz auf dem server ist
    $sqlAudioSpace = "SELECT *";
    $sqlAudioSpace .= " FROM zap_audio";
    $sqlAudioSpace .= " WHERE ";
    $sqlAudioSpace .= " artistID = " . $artistID;
    $rsAudioSpace = mysql_query($sqlAudioSpace);

    $anAudioSpace = mysql_num_rows($rsAudioSpace);


    while($crAudioSpace = mysql_fetch_assoc($rsAudioSpace)){
        $auSize = $crAudioSpace["audioSize"];
        $numGesamt += $crAudioSpace["audioSize"];
    }


    $auGesamtSize = $numGesamt + $audioName_size;
    //$auGesamtSize = bcdiv($numGesamt, 1000000, 2);
    $auReal = $auGesamtSize / 1000000;
    $auRealGesamt = round ($auReal, 2);

    if ($auRealGesamt > $mySpace){
        header("Location: ../media.php?uperror=File is too large!");
        die();
    }else{

        //ende errechne ob file uploaded werden darf

        //$audioName = "audioName";
        $maxSize = 1000 * 12000;
        $audioUploadPath = "../../hluistm4nbt2elsOq/";


        // ende vars die gesetzt werden

        // get the right filetype
        $fileType = $audioName_type;
        //the file type will be like'image/jpeg'
        $fileTypePieces = explode("/" , $fileType);
        //$imageType will be 'jpeg'
        $imageType = $fileTypePieces[1];

        if($imageType == "mpeg"){
            $theFileType = "mp3";
        }
        else if($imageType == "mp3"){
            $theFileType = "mp3";
        }
        else if($imageType == "MP3"){
            $theFileType = "mp3";
        }
        else{ //if it is a filetype we do not want to support
            $theFileType = "";
        }

        // end get the right file type

        //
        //check to see if the users actually chose an image
        if($audioName_name != ""){

            if($audioName_size > $maxSize){

                header("Location: ../media.php?uperror=File is too large!");
                die();

            }else{//if the image is within our limits

                //test to see if the image is NOT of a supported type
                if($theFileType == ""){
                    header("Location: ../media.php?uperror=Filetype not supported!");
                    die();
                }else{

                    list($ar,$aID) = explode("__",$_POST["audioRelease"]);
                    //echo $ar . $aID;
                    //exit;


                    //insert the new image into the database
                    $sqlInsertImage = "INSERT INTO zap_audio(releaseID, audioRelease, audioInfo, audioName, audioFileName, audioSize, audioType, artistID)";
                    $sqlInsertImage .= "VALUES('".$aID."' , '".$ar."' , '".$_POST["audioInfo"]."' , '".$_POST["audioSongName"]."' , '$audioName_name' , '$audioName_size' , '$audioName_type' , '$artistID' )";
                    $insertImage = mysql_query($sqlInsertImage);

                    //get the inserted image ID
                    $audioID = mysql_insert_id();



                    //change the name of the file to be unique
                    $audioNameNew = $audioID.".".$theFileType;  //example : 4.mp3
                    $filePath = $audioUploadPath . $audioNameNew ;

                    //update the images table to put the file path back in
                    $sqlUpdate = "UPDATE zap_audio SET audioPath = '" .$filePath . "' , audioFile = '" .$audioNameNew . "'WHERE audioID = " . $audioID ;
                    $exec = mysql_query($sqlUpdate );

Is there any chance you're using a CMS? eg Joomla?

There is a list of legal extension in the administration part.

Take a look at Unable to upload a file: This file type is not supported and try to add the extension you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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