2014-09-09 7 views
-1

나는이 스크립트를 사용하기 index.html을을 얻으려고 : 업로드 호출되는 (이에 연결하여 MP3 파일을 업로드하려면구문 분석 오류 : 구문 오류, 예기치 않은 '{'

<form action="upload.php" method="post" 
enctype="multipart/form-data"> 
<label for="file">Filename:</label> 
<input type="file" name="file" id="file" /> 
<br /> 
<input type="submit" name="submit" value="Upload" /> 
</form> 

을 .PHP) :

<?php 
if ((($_FILES["file"]["type"] == "audio/mp3") //File type 
|| ($_FILES["file"]["type"] == "audio/mp3")) 
&& ($_FILES["file"]["size"] < 21000000) //20MB File Size 
    { 
    if ($_FILES["file"]["error"] > 0) 
    { 
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; 
    } 
    else 
    { 
    echo "";//another echo to display after upload is complete 

    if (file_exists("mp3/" . $_FILES["file"]["name"])) 
     { 
     echo $_FILES["file"]["name"] . " already exists. "; 
     } 
    else 
     { 
     move_uploaded_file($_FILES["file"]["tmp_name"], 
     "mp3/" . $_FILES["file"]["name"]); 
//Below shows the link for the mp3 
     echo "http://www.Domain here". "mp3/" . $_FILES //Only change domain here leave directory 

["file"]["name"] .""; 
     } 
    } 
    } 
else 
    { 
    echo "Extension not allowed"; //Error message here if it's to big or wrong extension 
    } 
?> 

그러나 나는 항상이 오류가지고 바람 : 나는 추가하여 문제 나 자신을 찾기 위해 노력했습니다

Parse error: syntax error, unexpected '{' in /var/www/xxxx/test/upload.php on line 5 

을/remov ing}의 스택 오버플로에 대한 항목을 살펴본 후 실패했지만 실패했습니다. 누가 잘못되었는지 말해 줄 수 있니? 미리 감사드립니다!

답변

5

당신은 정말 닫는에게 분명한의 )

if ((($_FILES["file"]["type"] == "audio/mp3") //File type 
|| ($_FILES["file"]["type"] == "audio/mp3")) 
&& ($_FILES["file"]["size"] < 21000000)) //20MB File Size 
    { 

종류를 놓치고있어.

1
<?php 
    if ((($_FILES["file"]["type"] == "audio/mp3") 
    || ($_FILES["file"]["type"] == "audio/mp3")) 
    && ($_FILES["file"]["size"] < 21000000)) { 
     if ($_FILES["file"]["error"] > 0) { 
      echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; 
     } else { 
      echo ""; //another echo to display after upload is complete 

      if (file_exists("mp3/" . $_FILES["file"]["name"])) { 
       echo $_FILES["file"]["name"] . " already exists. "; 
      } else { 
       move_uploaded_file($_FILES["file"]["tmp_name"], "mp3/" . $_FILES["file"]["name"]); 
       //Below shows the link for the mp3 
       echo "http://www.Domain here" . "mp3/" . $_FILES["file"]["name"] . ""; //Only change domain here leave directory 

      } 
     } 
    } else { 
     echo "Extension not allowed"; //Error message here if it's to big or wrong extension 
    } 
?> 
관련 문제