• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 3年前 (2022-01-24) 12次浏览 已收录 0个评论

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

HTML code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>upload.</title><style type="text/css"><!---ecms .STYLE2 {    font-family: "宋体";    font-weight: bold;}--></style><body><style type="text/css"><!---ecms tr,td{font-size:10px}--></style>    <h1 class="STYLE2">upload your file</h1>    <p>    <table border="1" cellspacing="0" cellpadding="1" width="400">        <tr bgcolor="#ccccff">    <td>chose your file:</td>    <td></td>    </tr>    <tr>    <td>describe:</td>    <td></td>    </tr>    <tr>    <td>owner:</td>    <td></td>    </tr>    <tr>    <td>submit:</td>    <td></td>    </tr>        </table>    </p>        

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

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpif (!$_POST["upfile"]&&$_FILES["upfile"]["name"]==""){    echo "no file<p>";    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 "<p>";        echo "is upload successfull.<p>";        echo "clicktherereturn!";    }    else     {        echo "upload error!<p>";        echo "fail!<p>";        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:\phpno+本文来源gao@daima#com搞(%代@#码网

搞代gaodaima码

w\htdocs\b\up_back.php on line 10


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:一个关于文件下传的页面.遇到异常.求大神指导指导
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址