我想在我的文件夹中上传多个图像,并将它们存储在我的SQL数据库中。但是我似乎做不到。当我运行此代码时,我没有任何错误或任何错误。我错过了什么?谢谢您的帮助!
<?php
include ("dbconnect.php");
if(isset($_POST['btn_upload']))
{
for($i = 0; $i < count($_FILES['file_img']['name']); $i++)
{
$filetmp = $_FILES["file_img"]["tmp_name"][$i];
$filename = $_FILES["file_img"]["name"][$i];
$filetype = $_FILES["file_img"]["type"][$i];
$filepath = "photo/".$filename;
move_uploaded_file($filetmp,$filepath);
$sql = "INSERT INTO image (homeImage) VALUES ('$filename')";
$result = mysql_query($con, $sql);
}
}
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file_img[]" multiple />
<input type="submit" name="btn_upload" value="Upload">
</form>
</body>
</html>