Загрузить 3 фото в php

У меня возникли проблемы с загрузкой фотографий для моего TP. У меня есть первая фотография, которая идет хорошо, а вторая и третья ничего. Я поместил необработанное изображение в базу данных, а затем вернулся на сайт, чтобы протестировать его в загружаемом файле, он удаляет мою ссылку на изображение, но у меня нет новых, которые заменяют его и нет изображения на сервере.

Вот мой код:

$image = "";$image_2 = "";
$image_3 = "";
 
if(isset($_FILES['pointpicture']) AND !empty($_FILES['pointpicture']['name']))
{
    $taillemax = 2097152;
    $extensionvalides = array('jpg','jpeg','png');
     
    if($_FILES['pointpicture']['size'] <= $taillemax)
    {
        $extensionupload = strtolower( substr(strrchr($_FILES['pointpicture']['name'],'.'),1));
         
        if(in_array($extensionupload,$extensionvalides))
        {
            $img = RandomString();
            $chemin = $abs_path."images/pointpictures/".$img.".".$extensionupload;
            $image = "images/pointpictures/".$img.".".$extensionupload;
            $resultat = move_uploaded_file($_FILES["pointpicture"]["tmp_name"], $chemin);
             
            if($resultat)
            {
                //select current user old profile picture name
                $avatar = $mysqli->query("SELECT image FROM pointsofinterest WHERE id = ".$pointid )->fetch_object()->image;
                $filename = $abs_path."images/pointpictures/".$avatar;
                if (file_exists($filename)) {
                    unlink($filename);
                }
                system('chmod 775 "'.$chemin.'"');
            }
            else { header('Location: '.$base_url.'mespoints?modif=uploaderror'); }
        } else { header('Location: '.$base_url.'mespoints?modif=badformat'); }
         
    } else { header('Location: '.$base_url.'mespoints?modif=picistofat'); }
}
else
{
    $image = $mysqli->query("SELECT image FROM pointsofinterest WHERE id = '".$pointid."'")->fetch_object()->image;
}
 
if(isset($_FILES['pointpicture2']) AND !empty($_FILES['pointpicture2']['name']))
{
    $taillemax = 2097152;
    $extensionvalides = array('jpg','jpeg','png');
     
    if($_FILES['pointpicture2']['size'] <= $taillemax)
    {
        $extensionupload = strtolower( substr(strrchr($_FILES['pointpicture2']['name'],'.'),1));
         
        if(in_array($extensionupload,$extensionvalides))
        {
            $img = RandomString();
            $chemin = $abs_path."images/pointpictures/".$img.".".$extensionupload;
            $image_2 = "images/pointpictures/".$img.".".$extensionupload;
            $resultat = move_uploaded_file($_FILES["pointpicture2"]["tmp_name"], $chemin);
             
            if($resultat)
            {
                //select current user old profile picture name
                $avatar = $mysqli->query("SELECT image_2 FROM pointsofinterest WHERE id = ".$pointid )->fetch_object()->image;
                $filename = $abs_path."images/pointpictures/".$avatar;
                if (file_exists($filename)) {
                    unlink($filename);
                }
                system('chmod 775 "'.$chemin.'"');
            }
            else { header('Location: '.$base_url.'mespoints?modif=uploaderror'); }
        } else { header('Location: '.$base_url.'mespoints?modif=badformat'); }
         
    } else { header('Location: '.$base_url.'mespoints?modif=picistofat'); }
}
else
{
    $image_2 = $mysqli->query("SELECT image_2 FROM pointsofinterest WHERE id = '".$pointid."'")->fetch_object()->image;
}
 
if(isset($_FILES['pointpicture3']) AND !empty($_FILES['pointpicture3']['name']))
{
    $taillemax = 2097152;
    $extensionvalides = array('jpg','jpeg','png');
     
    if($_FILES['pointpicture3']['size'] <= $taillemax)
    {
        $extensionupload = strtolower( substr(strrchr($_FILES['pointpicture3']['name'],'.'),1));
         
        if(in_array($extensionupload,$extensionvalides))
        {
            $img = RandomString();
            $chemin = $abs_path."images/pointpictures/".$img.".".$extensionupload;
            $image_3 = "images/pointpictures/".$img.".".$extensionupload;
            $resultat = move_uploaded_file($_FILES["pointpicture3"]["tmp_name"], $chemin);
             
            if($resultat)
            {
                //select current user old profile picture name
                $avatar = $mysqli->query("SELECT image_3 FROM pointsofinterest WHERE id = ".$pointid )->fetch_object()->image;
                $filename = $abs_path."images/pointpictures/".$avatar;
                if (file_exists($filename)) {
                    unlink($filename);
                }
                system('chmod 775 "'.$chemin.'"');
            }
            else { header('Location: '.$base_url.'mespoints?modif=uploaderror'); }
        } else { header('Location: '.$base_url.'mespoints?modif=badformat'); }
         
    } else { header('Location: '.$base_url.'mespoints?modif=picistofat'); }
}
else
{
    $image_3 = $mysqli->query("SELECT image_3 FROM pointsofinterest WHERE id = '".$pointid."'")->fetch_object()->image;
}
 
$requete = "UPDATE pointsofinterest SET categorie = '".$pointcat."', titre = '".$pointname."', address = '".$pointaddress."', tel = '".$pointphone."',
            longitude = '".$pointlong."', latitude = '".$pointlat."', keywords = '".$pointkeywords."', email = '".$pointemail."', website = '".$pointwebsite."',
            description = '".$pointdesc."', facility = '".$pointfacility."', facebook = '".$pointfacebook."', instagram = '".$pointinstagram."', twitter = '".$pointtwitter."',
            horairesLundi = '".$pointhoraireslundi."', horairesMardi = '".$pointhorairesmardi."', horairesMercredi = '".$pointhorairesmercredi."',
            horairesJeudi = '".$pointhorairesjeudi."', horairesVendredi = '".$pointhorairesvendredi."', horairesSamedi = '".$pointhorairessamedi."',
            horairesDimanche = '".$pointhorairesdimanche."', image = '".$image."', image_2 = '".$image_2."', image_3 = '".$image_3."' WHERE id = '".$pointid."'";
 
mysqli_query($mysqli, $requete);

php,mysql,image,upload,photo,

0
Яндекс.Метрика