好傢伙,請幫忙! 我有我的項目的問題,我跟着就如何上傳(https://www.youtube.com/watch?v=Ipa9xAs_nTg)這些步驟,但什麼是錯的。
錯誤是注意:上傳照片MySQL和顯示器使用PHP
未定義指數:tmp_name的值在C:\ XAMPP \ htdocs中\ LDEVERACATERING \ upload_process.php第16行
這裏是我的upload.html
<!DOCTYPE html>
<html>
<head>
<script src="jquery-3.2.1.min"></script>
<script src="jquery-migrate-1.4.1.min"></script>
<title>
Image Upload
</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="content">
<form method="POST" action="upload_process.php" enctype="multipart/form-data">
<input type="hidden" name="size" value="1000000"/>
<div>
<input type="file" name="image"/>
</div>
<div>
<textarea name="text" cols="40" rows="4" placeholder="Say something about this image..."></textarea>
</div>
<div>
<input type="submit" name="upload" value="Upload Image"/>
</div>
</form>
</div>
</body>
</html>
這裏是我的upload_process.php
<?php
$msg = "";
//if upload button is pressed
if (isset($_POST['upload'])) {
//path to store the upload image
$target = "photos/".basename($_FILES['image']['name']);
//connect to database
$db = mysqli_connect("localhost", "root", "", "catering_info");
}
//get all the submitted date from the form
$image = $_FILES['image']['name'];
$text = $_POST['text'];
$sql = "INSERT INTO photos_upload(image, text) VALUES('$image', '$text')";
mysqli_query($db, $sql); //stores the submitted date into the database table: images
//now let's move the upload image into the folder: photos
if (move_uploaded_file($_FILES['tmp_name']['name'], $target)) {
$msg = "Image uploaded successfully";
}
else
{
$msg = "There was a problem uploading image";
}
?>
請幫助我,我真的需要它。另外我還是新來這個,我剛開始網絡PROG過去的3周:(非常感謝你!
閱讀本教程:https://www.w3schools.com/php/php_file_upload.asp –