在一列中以逗号分隔的列表形式插入多个图像

isr3a4wc  于 2021-06-23  发布在  Mysql
关注(0)|答案(0)|浏览(201)

我正在创建一个房地产web应用程序,现在创建一个表单,允许编辑器输入有关某个属性的数据,其中包括图像,但我不知道如何在数据库的一列中输入多个值。这是我的密码。

if(!empty($_FILES)){
    $photo1 = $_FILES['photo1'];
    $photo2 = $_FILES['photo2'];
    $photo3 = $_FILES['photo3'];
    $photo4 = $_FILES['photo4'];
    $photo5 = $_FILES['photo5'];
    $photo6 = $_FILES['photo6'];
    $photo7 = $_FILES['photo7'];
    $photo = [$photo1,$photo2,$photo3,$photo4,$photo5,$photo6,$photo7];
    foreach ($photo as $photos) {
        $name = $photos['name'];
        $nameArray = explode('.',$name);
        $filename = $nameArray[0];
        $fileEXT = $nameArray[1];
        $mime = explode('/', $photos['type']);
        $mimeType = $mime[0];
        $mimeEXT = $mime[1];
        $temploc = $photos['tmp_name'];
        $filesize = $photos['size'];
        $allowed = array('png','jpg','jpeg','gif',);
        $uploadname = md5(microtime()).'.'.$fileEXT;
        $uploadpath = LINKURL.'/imgs/photos/'.$uploadname;
        $dbpath = '/realeastate/imgs/photos/'.$uploadname;
        if($mimeType != 'image'){
            $errors[]= 'File must be an image';
        }
        if(!in_array(strtolower($fileEXT), $allowed)){
            $errors[]= 'The photo extension must be jpg,png,jpeg or gif.';
        }
        if($filesize > 25000000){
           $errors[]= 'The file size must be less than 25MB.';
        }
        if(strtolower($fileEXT) != $mimeEXT && $mimeEXT == 'jpeg' && strtolower($fileEXT) != 'jpg' ){
            $errors[]= 'File extension does not match the file.';
        }

        if(!empty($errors)){
            echo show_errors($errors);
      } else {
            //upload file and insert into database
            if (!empty($_FILES)) {
                move_uploaded_file($temploc,$uploadpath);
            }
            if(isset($_GET['edit'])){
                $db->query("UPDATE property SET taken ='$taken' WHERE id ='$edit_id'");
            }else{ 
                $db->query("INSERT INTO property (category,status,purpose,cover,images,city,place,price,payment,garage,wideness,visit,takenhome,hospital,school,market,bank,church,mosque,government,datetostart,floor) VALUES ('$category','$status','$purpose','$dbpath','$city','$place','$price','$payment','$garage','$wide','$dprice','$adprice','$hospital','$school','$church','$mosque','$government','$opendate','$floor')");
            }

        }

    }

    $_SESSION['success'] = 'Property  Added successful';
    header('Location: house.php');

 }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题