Galerie photos

Fermé
LaChaux78 Messages postés 564 Date d'inscription lundi 25 juillet 2016 Statut Membre Dernière intervention 31 mars 2023 - Modifié le 15 juin 2019 à 21:36
LaChaux78 Messages postés 564 Date d'inscription lundi 25 juillet 2016 Statut Membre Dernière intervention 31 mars 2023 - 16 juin 2019 à 22:45
Bonjour, je voudrais essayer de construire une galerie photos. Malheureusement j'ai quelques soucis. En fait j'autorise uniquement les extensions image et malgrès cela dans mon dossier n'importe quelle extension peut être exporter sauf dans ma BDD seuls les extensions autorisés sont insérés.
Pouvez-vous me donner votre avis s'ils vous plait.Je vous remercie.
$action  = 'new';
$a    = !empty($_GET['a']) ? $_GET['a'] : NULL;
$submit  = !empty($_POST['submit']) ? $_POST['submit'] : NULL;
$haction  = !empty($_POST['haction']) ? $_POST['haction'] : NULL;

$idfoto  = !empty($_REQUEST['idfoto']) ? $_REQUEST['idfoto'] : NULL;
$datefoto  = !empty($_POST['datefoto']) ? dw2m($_POST['datefoto']) : '';
$lieufoto  = !empty($_POST['lieufoto']) ? strtoupper($_POST['lieufoto']) : '';
$descfoto  = !empty($_POST['descfoto']) ? ucwords($_POST['descfoto']) : '';
$resfoto  = !empty($_POST['resfoto']) ? $_POST['resfoto'] : '';
$sizefoto  = !empty($_POST['sizefoto']) ? $_POST['sizefoto'] : '';
$urlfoto  = !empty($_POST['urlfoto']) ? strtolower($_POST['urlfoto']) : '';
$files   = !empty($_FILES['namefoto']) ? $_FILES['namefoto'] : NULL;
$fileName  = !empty($files['name']) ? $files['name'] : NULL;
$fileTemp  = !empty($files['tmp_name']) ? $files['tmp_name'] : NULL;

switch($a) {
 case 'new': $action = 'new';  break; 
 default   : $action = 'new';  break; 
}

if($submit) {

 switch($haction) {
  case 'new':

  $dossier = '/home/azerty/www/album/orig/'.date("Y", strtotime($datefoto)).'/'.$lieufoto.'/';
  if(!is_dir('/home/azerty/www/album/orig/'.date("Y", strtotime($datefoto)).'/'.$lieufoto.'/')) {
     mkdir('/home/azerty/www/album/orig/'.date("Y", strtotime($datefoto)).'/'.$lieufoto.'/', 0755, true);
  }
  $min = '/home/azerty/www/album/min/'.date("Y", strtotime($datefoto)).'/'.$lieufoto.'/';
  if(!is_dir('/home/azerty/www/album/min/'.date("Y", strtotime($datefoto)).'/'.$lieufoto.'/')) {
     mkdir('/home/azerty/www/album/min/'.date("Y", strtotime($datefoto)).'/'.$lieufoto.'/', 0755, true);
  }
  
  $ext_valide = array('jpg', 'gif', 'png', 'jepg');
  $ext_upload = strtolower(  substr(  strrchr($fileName, '.')  ,1)  );
  $file_new = '' .time(). '.' . $ext_upload;
  $file_dest = $dossier.$file_new;
  $file_upload = move_uploaded_file($fileTemp, $file_dest);
  $taille_maxi = 2000000;
  $taille = filesize($file_dest);
  
  if($taille > $taille_maxi) {
   $erreur = '<span class="erreur">Le fichier envoyer est trop volumineux !</span>';
  } else {  
  
   if (is_dir($dossier) && is_writable($dossier)) {
    if (in_array($ext_upload,$ext_valide)) {
     if ($file_upload) {
     //Chemin vers l'image uploder, nouveau chemin, nouveau nom de l'image
     Img::creerMin($dossier, $min, $file_new, 215, 112);
  
     $sql = "INSERT INTO cdc_galeries (namefoto, datefoto, lieufoto, descfoto, resfoto, sizefoto, urlfoto) VALUES (:namefoto, :datefoto, :lieufoto, :descfoto, :resfoto, :sizefoto, :urlfoto)";
     $datas = array('namefoto' => $file_new, 'datefoto' => $datefoto, 'lieufoto' => $lieufoto, 'descfoto' => $descfoto, 'resfoto' => $resfoto, 'sizefoto' => $taille, 'urlfoto' => $dossier);
     $result = executeQuery($sql,$datas);
     $typenr = "enregistré";
     $reqaj = $requete;
     $success = "<span class='success'>La nouvelle photo du - ".dFR("$datefoto")." - a été $typenr.</span>";
     
     }
    } else {
     $erreur = "<span class='erreur'>Seuls les fichiers PDF sont autorisés!</span>";
    }
   } else {
    $erreur = "<span class='erreur'> Echec lors de l'upload du fichier ".$file_dest."</span>";
   }
  }
  break;
 }
}
A voir également:

1 réponse

LaChaux78 Messages postés 564 Date d'inscription lundi 25 juillet 2016 Statut Membre Dernière intervention 31 mars 2023 32
16 juin 2019 à 22:45
Bonjour j'ai trouvé mon erreur.
0