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的人。
答案 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!";
}