当前位置:Gxlcms > PHP教程 > 一个关于文件上传的页面.遇到异常.求大神指导指导

一个关于文件上传的页面.遇到异常.求大神指导指导

时间:2021-07-01 10:21:17 帮助过:14人阅读

一个关于文件上传的页面.遇到错误.求大神指导指导





upload.






upload your file












这个是用来前台的页面调用下面的php.

if (!$_POST["upfile"]&&$_FILES["upfile"]["name"]=="")
{
echo "no file

";
echo "clicktherereturn!";
}
else
{
$filepath="upload/";
$name=$filepath.$_FILES["upload"]["name"];
while (file_exists($name))
{
$temp=explode(".", $name);
$name=$temp[0]."0".".".$temp[1];
}
if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $name))
{
if ($_POST["owner"])
{
$owner=$_POST["owner"];
}
else
{
$owner="NULL";
}
if ($_POST["describe"])
{
$describe=$_POST["describe"];
}
else
{
$describe="NONE";
}
$time=date("y-m-d H:m:s");
$content=$_FILES["upload"]["name"]."||".$owner."||".$describe."||".$time."\n";
file_put_contents("record.dat", $content.FILE_APPEND);
echo "name:".$_FILES["upfile"]["name"];
echo "

";
echo "is upload successfull.

";
echo "clicktherereturn!";
}
else
{
echo "upload error!

";
echo "fail!

";
echo "clicktherecheck!";
}
}
?>


问题就在于上传之后,提示文件上传成功,但是upload文件夹里面文件名是0的倍数,而且没有文件格式..这个是怎么回事呢?


提示的错误就是下面这些..
Notice: Undefined index: upfile in D:\phpnow\htdocs\b\up_back.php on line 2

Notice: Undefined index: upload in D:\phpnow\htdocs\b\up_back.php on line 10

Notice: Undefined offset: 1 in D:\phpnow\htdocs\b\up_back.php on line 14

人气教程排行