php文件上传的问题
我用php写了一个简单的文件上传的页面,显示上传成功了,但
(1)、对应目录下却没有上传的文件【tmp目录下没有文件,也没有生成upload目录和文件】。
(2)、move_uploaded_file的参数顺序,代码中上一行的为错误的,下一行正确,与教材上的相反。
求大神解惑。
upload.html
<br /> <form action = "upload_file.php" method = "post" enctype = "multipart/form-data"><br /> <label for = "file">Filename</label><br /> <input type = "file" name = "file" id = "file"/><br /> <br><br /> <input type = "submit" name = "submit" value = "上传"/><br /> <br /> </form><br />
<br /> <?php<br /> if($_FILES["file"]["error"] > 0)<br /> {<br /> echo "Error : ".$_FILES["file"]["error"]."<br>";<br /> }<br /> else<br /> {<br /> echo "Upload: ".$_FILES["file"]["name"]."<br>";<br /> echo "Type: ". $_FILES["file"]["type"]."<br>";<br /> echo "Size: ".($_FILES["file"]["size"]/1024)."KB<br>";<br /> echo "Stored in: ".$_FILES["file"]["tmp_name"]."<br>";<br /> <br /> if(file_exists("upload/".$_FILES["file"]["name"]))<br /> {<br /> echo $_FILES["file"]["name"]." already exists.";<br /> }<br /> else<br /> {<br /> //move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$_FILES["file"]["name"]);// 报错<br /> move_uploaded_file("upload/".$_FILES["file"]["name"],$_FILES["file"]["tmp_name"]);<br /> echo "<br><br><br> Storeed in: "."upload/".$_FILES["file"]["name"];<br /> }<br /> <br /> <br /> }<br /> <br /> <br /> <br /> ?><br />