嗨我試圖創建一個簡單的上傳PHP表單,但是當我上傳PDF我收到第8行的錯誤消息,這裏是我的代碼;簡單上傳PHP表單問題
(代碼更新)
<?php
if(isset($_POST['submit']))
{
$errors= array();
$file_name = $_FILES['uploadFile']['name'];
$file_size =$_FILES['uploadFile']['size'];
$file_tmp =$_FILES['uploadFile']['tmp_name'];
$file_type=$_FILES['uploadFile']['type'];
$value = explode(".", $file_name);
$file_ext = strtolower(array_pop($value));
$expensions= array("pdf");
if(in_array($file_ext,$expensions)== false)
{
$errors="Extension not allowed, please choose a PDF file.";
}
if($file_size > 9097152)
{
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true)
{
move_uploaded_file($file_tmp,"client_files/bond/uploads/".$file_name);
//include here insert query**
echo "The file ".$file_name." has been uploaded.";
//echo "Success";
}
else
{
print_r($errors);
}
}
?>
而在我的HTML文件中的主體由一個簡單的表格;
<div class="body"></div>
<div class="grad"></div>
<div class="header">
<div>Logo<span>Here</span></div>
</div>
<br>
<div class="login">
<form action="upload.php" method="post" enctype="multipart/form-data">
Please choose a file: <input type="file" name="uploadFile"><br>
<input type="submit" value="Upload File">
</form>
</div>
定義了「$ pdf」嗎? – 2014-10-20 07:55:50
什麼是確切的錯誤消息,你在哪裏定義了'$ pdf'? – Rizier123 2014-10-20 07:58:47
致命錯誤:調用第8行的/public_html/bond/upload.php中的非對象的成員函數Output(),我感覺它的原因$ pdf未定義我需要添加到pdf中以定義什麼它? – user3607744 2014-10-20 08:00:11