vendredi 25 décembre 2020

If statement checking the array

**Html Code**
    <input type="file" class="custom-file-input" id="imagefile" name="imagefile[]"  multiple lang="en">
    <input type="hidden" name="hidden_imagefile[]" value="<?=$row[2]; ?>" class="form-control border-input" >

**Php Code**    
        if($_FILES['imagefile']['name'] == '')
            {
              $img = $_POST['hidden_imagefile'];
            }
            else{
              $img = '';
              $uploadFolder = 'uploads/gallery/';
              foreach ($_FILES['imagefile']['tmp_name'] as $key => $image) {
                $imageTmpName = time() .$_FILES['imagefile']['tmp_name'][$key];
                $imageName = time() .$_FILES['imagefile']['name'][$key];
                $img .= $imageName.',';
                $result = move_uploaded_file($imageTmpName, $uploadFolder.$img);
              }
              
            }
**Html Code**
**Html Code**
<input type="file" class="custom-file-input" id="imagefile" name="imagefile[]"  multiple lang="en">
    <input type="hidden" name="hidden_imagefile[]" value="<?=$row[2]; ?>" class="form-control border-input" >

**PHP Code**
<?php
  
  if(isset($_POST['upload']))
  {
    $videourl=$_POST['videourl'];
    $titles=$_POST['titles'];
    $dates=$_POST['dates'];
    $createdat=date("m/d/Y H:i:s A");
    $updatedat=date("m/d/Y H:i:s A");
    
    if($_FILES['imagefile']['name'] == '')
    {
      $img = $_POST['hidden_imagefile'];
    }
    else{
      $img = '';
      $uploadFolder = 'uploads/gallery/';
      foreach ($_FILES['imagefile']['tmp_name'] as $key => $image) {
        $imageTmpName = time() .$_FILES['imagefile']['tmp_name'][$key];
        $imageName = time() .$_FILES['imagefile']['name'][$key];
        $img .= $imageName.',';
        $result = move_uploaded_file($imageTmpName, $uploadFolder.$img);
      }
    }
    
    $qry=mysqli_query($con,"UPDATE `gallerys` SET `titles`='".$titles."',`imagefile`='$img',`videourl`='".$videourl."',`dates`='".$dates."',`createdat`='".$createdat."',`updatedat`='".$updatedat."' WHERE id='$uid'");
    if($qry)
    {
      $_SESSION['success']="Updated Successfully";
      echo "<script>window.location.href='#'</script>";
    }
    else{
      $_SESSION['error']="Failed";
      echo "<script>window.location.href='#'</script>";
    }
  }
  ?>

Aucun commentaire:

Enregistrer un commentaire