我正在尝试将php图像上传到数据库,但是我使用的Windows版本似乎有问题...我在笔记本电脑(Win 10)上使用与PC(Win 10)相同的代码8),但是在我的笔记本电脑上,代码不起作用。我的电脑上的表格运行正常。我使用的是相同的文件,相同的数据库,相同的数据库表,相同的php版本,相同的php.ini设置...除Windows版本外,其他所有内容都相同。在我的笔记本电脑上,我收到错误未定义的索引:文件中...。如何解决该问题?
<?php
$submit = $_POST["submit"];
if(!isset($submit))
{
$URL="index.php";
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
}
else
{
require 'inc/dbconn.php';
$directory = "uploadings/";
$file = $directory . basename($_FILES["picture"]["name"]);
$imageFileType = strtolower(pathinfo($file,PATHINFO_EXTENSION));
$check = getimagesize($_FILES["picture"]["tmp_name"]);
$name = $_POST["product"];
$price = $_POST["price"];
if ($check == false) {
echo "File is not an image";
}
elseif (empty($name)) {
echo "Empty productname";
}
elseif (empty($price)) {
echo "Empty price";
}
else {
$stmt = $conn->prepare("INSERT INTO tbupload(picture, product, price) VALUES(?, ?, ?)");
$stmt->bind_param("ssi", $file, $name, $price);
$stmt->execute();
$stmt->close();
$conn->close();
$upload = move_uploaded_file($_FILES["picture"]["tmp_name"], $file);
$URL="view.php";
echo "<script type='text/javascript'>document.location.href='{$URL}';</script>";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
}
}
?>