首页 文章

通过php上传MP3文件

提问于
浏览
0

我有一个问题,通过我的PHP网站上传一个MP3文件 . 它允许我加载2MB以下的所有东西但没有结束 . 它以前工作过

托管服务提供商在您的域目录中增加了fastcgi超时限制.htaccess文件并添加了以下内容:php_value max_execution_time 300,

我们还增加了fastcgi超时限制并添加了一个.htaccess文件:php_value upload_max_filesize 20M php_value post_max_size 20M

该网站回来说不支持filetype .

请参阅以下一些代码 . 在此先感谢您的帮助 .

//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 );

2 回答

相关问题