我讓表單直接在數據庫中存儲圖像,現在我想學習如何將它們存儲在一個文件夾中,並將數據存儲在路徑中。將圖像上傳到數據庫未定義索引
在這一刻我得到這個錯誤Notice: Undefined index: uploaded_file in
,我真的不明白爲什麼。請一些F1 :) HTML表單:
<form action="ad_cont.php" method="POST" class="add_contact" name="add_contact" enctype="multipart/form-data">
<input type="file" name="uploaded_file" multiple required>
<input type="submit" value="Upload" class="button">
</form>
php腳本:
$img_path = "images/avatar";
$img_path = $img_path . basename($_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $img_path)) {
mysqli_query($conn,"INSERT INTO `uploads` (filename,path)
VALUES ('".$_FILES['uploaded_file']['tmp_name']."','".$img_path."')");
缺少加密類型。 –
enctype =「multipart/form-data」 – Xatenev