我想使用HTML POST方法和PHP將本地文件上傳到網絡服務器。 這是我的PHP代碼:使用HTML POST通過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 [ 「rawexcel」] [ 「錯誤」]表示0和運行這個代碼peice的我得到
error uploading file /var/tmp
我猜文件名是不是從HTML檢索?
你正在得到什麼錯誤......? – GYaN
更新的問題。總之 - 不能獲得文件名,$ upfile只有$ updir – upicik
upvotes on typo? *哇* –