php的move_uploaded_file函数,文件上传成功,但总出错误提示
<?php$file=$_FILES['file_test'];$tmp_name=$file['tmp_name'];$file_name=$file['name'];...
<?php
$file=$_FILES['file_test'];
$tmp_name=$file['tmp_name'];
$file_name=$file['name'];
move_uploaded_file($tmp_name,"./files/".$file_name);
if($error!=0)
exit("文件上传失败0");
if(!move_uploaded_file($tmp_name,"./files/".$file_name)){
exit("文件上传失败1");
}
else{
echo "文件上传成功";
}
?>
运行之后总是输出“文件上传失败1”
bool move_uploaded_file ( string $filename , string $destination )
php的说明上是这么写的啊。有bool型返回值的 展开
$file=$_FILES['file_test'];
$tmp_name=$file['tmp_name'];
$file_name=$file['name'];
move_uploaded_file($tmp_name,"./files/".$file_name);
if($error!=0)
exit("文件上传失败0");
if(!move_uploaded_file($tmp_name,"./files/".$file_name)){
exit("文件上传失败1");
}
else{
echo "文件上传成功";
}
?>
运行之后总是输出“文件上传失败1”
bool move_uploaded_file ( string $filename , string $destination )
php的说明上是这么写的啊。有bool型返回值的 展开
3个回答
展开全部
if(!move_uploaded_file($tmp_name,"./files/".$file_name)){
exit("文件上传失败1");
}
move_uploaded_file($tmp_name,"./files/".$file_name)已经在前面执行一次了,所以就出现错误。应该改为:
<?php
$file=$_FILES['file_test'];
$tmp_name=$file['tmp_name'];
$file_name=$file['name'];
$result = move_uploaded_file($tmp_name,"./files/".$file_name);
if(!$result){
exit("文件上传失败1");
}
else{
echo "文件上传成功";
}
?>
exit("文件上传失败1");
}
move_uploaded_file($tmp_name,"./files/".$file_name)已经在前面执行一次了,所以就出现错误。应该改为:
<?php
$file=$_FILES['file_test'];
$tmp_name=$file['tmp_name'];
$file_name=$file['name'];
$result = move_uploaded_file($tmp_name,"./files/".$file_name);
if(!$result){
exit("文件上传失败1");
}
else{
echo "文件上传成功";
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询