我的方法是创建三个输入文件,将其发布到数据库表中的三个不同列。
继承我的参数:
$additional_comments=$_POST['additional_comments'];
$image_one = $_FILES['image_one']['type'];
$image_two = $_FILES['image_two']['type'];
$image_three = $_FILES['image_three']['type'];
if($image=="image/jpeg" || $image=="image/jpg" || $image=="image/gif" || $image=="image/png")
{
$gambar_satu = $foldername . basename($_FILES['image_one']['name']);
$gambar_dua = $foldername . basename($_FILES['image_two']['name']);
$gambar_tiga = $foldername . basename($_FILES['image_three']['name']);
if ( move_uploaded_file
($_FILES['image']['tmp_name'], $gambar_satu)
($_FILES['image']['tmp_name'], $gambar_dua)
($_FILES['image']['tmp_name'], $gambar_tiga)
)
{
$stmt = $mysqli->prepare
("INSERT INTO table...
在if (move_uploaded_file...
我试图插入三个参数,它们是$gambar_satu
,$gambar_dua
,$gambar_tiga
。
我的问题是这样做的正确方法是怎样的?提前致谢。
答案 0 :(得分:0)
直接从php网站引用
<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "$uploads_dir/$name");
}
}
?>
希望它有所帮助!