2013-12-08 184 views
-1
if(is_uploaded_file($_FILES['file']['tmp_name'])) 
{ 
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); 
} 
print "Your file was successfully uploaded!"; 
} else { (This is my error.) 
print "Incorrect file extension!"; 
} 

爲什麼沒有其他的工作? 我似乎無法自己弄清楚,所以我決定問一個比我有更多PHP知識的人。爲什麼不是我的工作?

+1

看起來像一些括號與我不匹配。 – edtheprogrammerguy

回答

1

你有一個右括號很多:

if(is_uploaded_file($_FILES['file']['tmp_name'])) 
{ 
    move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); 
    print "Your file was successfully uploaded!"; 
} 
else 
{ 
    print "Incorrect file extension!"; 
} 
1

這是因爲

  • print語句是其間的ifelse語句。
  • 你有一個額外的大括號。

這裏是固定的代碼。

<?php 
if(is_uploaded_file($_FILES['file']['tmp_name'])) 
{ 
    move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); 
    print "Your file was successfully uploaded!"; 
} 
else 
{ 
print "Incorrect file extension!"; 
}