2016-05-28 8 views
0

ファイルのアップロードを処理するスクリプトがあります。 1 MB未満のファイルをアップロードしましたが、ファイルが1 MBを超えると、スクリプトは一時ファイルパスをnullに設定しているようです。以下にスクリプトを示します。PHP - Tempファイルのパスがnullです

$total = count($_FILES['DocName']['tmp_name']); 
    for($i = 0; $i < $total; $i++) { 

     // Get the temp file path 
     $tmpFilePath = $_FILES['DocName']['tmp_name'][$i]; 

     // Check if we have a path 
     if ($tmpFilePath != "") { 

      // Variables from form 
      $FolderName = $_POST['FolderName']; 
      $FolderName = stripslashes($FolderName); 
      $FolderName = mysql_real_escape_string($FolderName); 

      //Setup our new file path 

      // Check if folder name is home, if so, set the file path to that folder 
      if ($FolderName == "Home") { 
       $target_dir = "../../cdn.brmbc.com/usercontent/".$UserID."/"; 
      } 

      // If the folder name is not home, make the file go to that folder 
      else { 
       $IsInFolder = 1; 
       $target_dir = "../../cdn.brmbc.com/usercontent/".$UserID."/".$FolderName."/"; 
      } 

      $target_file = $target_dir . basename($_FILES["DocName"]["name"][$i]); 
      $FileType = pathinfo($target_file,PATHINFO_EXTENSION); 
      $DocumentName = $_FILES["DocName"]["name"][$i]; 

      echo $tmpFilePath . "<br>"; 
      echo $target_file . "<br>"; 
      echo $FileType . "<br>"; 
      echo $DocumentName . "<br>"; 
     } 

     // Go home if there is no temp path 
     else { 
      echo $tmpFilePath . "<br>" . "Failed to upload"; 
     } 
    } 

コードに誤りがありますか、これは単なるサーバーの問題ですか?

答えて

1

アップロードが1MB未満のファイルで機能する場合は、php.iniの設定と思われます。

php.iniにアクセスして「max_file_uploads」という設定を検索すると、1MBに設定されているはずです。

http://php.net/upload-max-filesize

0

私はあなたがphp.iniファイルを変更することがあると思います。 php.iniファイルには、

upload_max_filesize=2M 

のようなものがあります。そこでは、ファイルサイズを増やす必要があります。私はあなたのようだと思います

upload_max_filesize=1M 

ファイルサイズを増やした後はokeyにする必要があります。

関連する問題