当前位置: 首页 > 知识库问答 >
问题:

通过php上传MP3文件

蔡修远
2023-03-14

我有一个问题,通过我的php网站上传一个mp3文件。它允许我加载2MB以下的所有内容,但没有超过。它以前工作过

托管提供商还增加了fastcgi超时限制。htaccess文件,并添加以下内容:php\u value max\u execution\u time 300,

我们还增加了fastcgi超时限制,并添加了一个。htaccess文件:php\u值上传\u最大\u文件大小20M php\u值post\u最大\u大小20M

网站返回时说不支持文件类型。

请参阅下面的一些代码。提前感谢您的帮助。

//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个答案

关学
2023-03-14

阿帕奇身体怎么样?

http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody

仉梓
2023-03-14

有没有可能你用的是CMS?例如。Joomla?

行政部分有法定续延一览表。

看看无法上传文件:不支持此文件类型,并尝试添加所需的扩展名。

 类似资料:
  • 我试图创建一个apache2网页,允许用户上传nifti(. nii,.nii.gz)文件。 我尝试了两种不同的方法: > 在WSL Ubuntu 18.04上,“move_uploaded_文件($_文件[“fileToUpload”][“tmp_名称”],$target_文件)”不返回任何内容。它完全失败了。 在XAMPP上,页面可以获取PDF、JPG..等文件,但不能获取.nii、.exe(

  • 本文向大家介绍Dropbox API 在PHP中通过curl上传文件,包括了Dropbox API 在PHP中通过curl上传文件的使用技巧和注意事项,需要的朋友参考一下 示例 <ACCESS_TOKEN> 应该用OAuth 2访问令牌替换。

  • 问题内容: 选择图像,doc或pdf后,我想将它们通过okhttp3。如何进行此操作? 并在okhttp 3中 显示的错误是 谢谢。 问题答案: 所以我自己回答这个问题。 因此,我首先将输出流打开到一个临时文件。 扩展名取决于mime类型。您可以通过以下方式找到mime类型 现在从文件读取并将其内容写入临时文件 现在写入文件 最后 成功之后的最后

  • 问题内容: 我使用2个文件index.js,upload.php尝试通过ajax上传文件(img),如果成功追加到div 。 但是它不起作用,有几个问题,下面我的代码有什么建议吗? 谢谢。 upload.php 1. 还需要添加吗? 2. 并检查$ _FILES的大小或tmp_name是否仍使用? index.js 3.这几行是对的吗? 4.我错过或错了什么吗? 问题答案: 在其构造函数中接受一个

  • 问题内容: 我想使用将文件(特别是图像)上传到REST Server 。我已经导入/添加了构建路径和。而且我在堆栈跟踪中收到以下错误。 这有效吗? HTTP POST代码 堆栈跟踪 问题答案: 您似乎缺少依赖项。 我有,,并用和在我的类路径罐子。 我也使用而不是使用header属性。 查看Internet媒体类型以了解更多详细信息