我正在尝试使用HTML POST方法和PHP将本地文件上传到网络服务器。 这是我的PHP代码:
<?php
if (isset($_POST["submit"])) {
$updir = "/var/tmp/";
$upfile = $updir.basename($_FILES['rawexcel']['name']);
if(is_uploaded_file ($_FILES ["rawexcel"]["tmp_name"]))
{
move_uploaded_file ($_FILES["rawexcel"]["tmp_name"], $upfile);
} else {echo "error uploading file ".$upfile;}
} else {echo "not isset post method";}
?>
和HTML代码是:
<div class="container" id="upl">
<h4> Upload files</h4>
<form action="upl.php" enctype="mutipart/form-data" method="post">
<p> upload your files to DB</p>
<p><input type="file" name="rawexcel" id ="rawexcel">
<input type ="submit" value="Upload" name ="submit"></p>
</form>
</div>
$ _ FILES [&#34; rawexcel&#34;] [&#34;错误&#34;]显示0并且运行此代码片段
error uploading file /var/tmp
我猜文件名不是从html中检索的?
答案 0 :(得分:3)
错误在enctype中:
enctype="multipart/form-data"
不
enctype="mutipart/form-data"
答案 1 :(得分:1)
您在 enctype =“multipart / form-data”中输入错误,而不是键入 enctype =“ mutipart / form-data”< / em>。所以“多部分”拼写需要纠正。