为什么我的其他人不工作?

时间:2013-12-08 18:34:47

标签: php if-statement upload

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的人。

2 个答案:

答案 0 :(得分: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 :(得分:1)

那是因为

  • 您的 print 声明介于 if else 声明之间。
  • 你有一个额外的支撑。

这是固定代码。

<?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!";
}