Table of Contents
一个关于文件上传的页面.遇到异常.求大神指导指导
Jun 13, 2016 pm 12:48 PM
gt
lt
name
nbsp
一个关于文件上传的页面.遇到错误.求大神指导指导
<br /> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /> <html xmlns="http://www.w3.org/1999/xhtml"><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><br /> <title>upload.</title><br /> <style type="text/css"><br /> <!--<br /> .STYLE2 {<br /> font-family: "宋体";<br /> font-weight: bold;<br /> }<br /> --><br /> </style><br /> </head><br /> <br /> <body><br /> <style type="text/css"><br /> <!--<br /> tr,td{font-size:10px}<br /> --><br /> </style><br /> <center><br /> <h1 id="upload-nbsp-your-nbsp-file">upload your file</h1><br /> <p><br /> <table border="1" cellspacing="0" cellpadding="1" bordercolordark="#ffffff" bordercolorlight="#0000ff" width="400"><br /> <form action="up_back.php" method="post" enctype="multipart/form-data"><br /> <tr bgcolor="#ccccff"><br /> <td>chose your file:</td><br /> <td><input type="file" name="upfile" size=32 /></td><br /> </tr><br /> <tr><br /> <td>describe:</td><br /> <td><input type="text" name="describe" size="42" /></td><br /> </tr><br /> <tr><br /> <td>owner:</td><br /> <td><input type="text" name="owner" size="42" /></td><br /> </tr><br /> <tr><br /> <td>submit:</td><br /> <td><center><input type="submit" value="submit" /></center></td><br /> </tr><br /> </form><br /> </table><br /> </p><br /> </center><br /> <br /> <br /> </body><br /> </html>
Copy after login
这个是用来前台的页面调用下面的php.
<br /> <?php<br /> if (!$_POST["upfile"]&&$_FILES["upfile"]["name"]=="")<br /> {<br /> echo "no file<p>";<br /> echo "click<a href=\"up_forward.html\">there</a>return!";<br /> }<br /> else <br /> {<br /> $filepath="upload/";<br /> $name=$filepath.$_FILES["upload"]["name"];<br /> while (file_exists($name))<br /> {<br /> $temp=explode(".", $name);<br /> $name=$temp[0]."0".".".$temp[1];<br /> }<br /> if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $name))<br /> {<br /> if ($_POST["owner"])<br /> {<br /> $owner=$_POST["owner"];<br /> }<br /> else <br /> {<br /> $owner="NULL";<br /> }<br /> if ($_POST["describe"])<br /> {<br /> $describe=$_POST["describe"];<br /> }<br /> else<br /> {<br /> $describe="NONE";<br /> }<br /> $time=date("y-m-d H:m:s");<br /> $content=$_FILES["upload"]["name"]."||".$owner."||".$describe."||".$time."\n";<br /> file_put_contents("record.dat", $content.FILE_APPEND);<br /> echo "name:".$_FILES["upfile"]["name"];<br /> echo "<p>";<br /> echo "is upload successfull.<p>";<br /> echo "click<a href=\"up_forward.html\">there</a>return!";<br /> }<br /> else <br /> {<br /> echo "upload error!<p>";<br /> echo "fail!<p>";<br /> echo "click<a href=\"index.php\">there</a>check!";<br /> }<br /> }<br /> ?><br />
Copy after login
问题就在于上传之后,提示文件上传成功,但是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
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

How to enable or disable taskbar thumbnail previews on Windows 11

OOBELANGUAGE Error Problems in Windows 11/10 Repair

What are the differences between Huawei GT3 Pro and GT4?

10 Ways to Adjust Brightness on Windows 11
