<?php
include_once("../include/main.inc.php");
check_session('MyCpanel', 'index.php');
@extract($_REQUEST);
$catID = $_POST['catID'];
$heading = $_POST['toolipHeadingUp'];
$content = $_POST['toolTipContentUp'];
$images = $_FILES['toolipImageUp'];

for ($i = 0; $i < count($heading); $i++) {
   
    $target_dir = SITE_DIR_PATH . "/uploaded-files/category/caticon/";
    $cat1 = str_replace(" ", "-", $catname);
    $img_name1 = $cat1 . uniqid();
    $unique_name = $img_name1.uniqid(). '.' . strtolower(pathinfo($images["name"][$i], PATHINFO_EXTENSION));
    $target_file = $target_dir . $unique_name;

            move_uploaded_file($images["tmp_name"][$i], $target_file);
            $width = "319";
            $height = "198";
      
            $source_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon";
            $destination_folder = SITE_DIR_PATH . "/uploaded-files/category/caticon/thumbs/";
            saveResizedPhoto($unique_name, $width, $height, $source_folder, $destination_folder);

            $sql = mysqli_query($GLOBALS['dbconn'], "insert into category_tooltip_tbl set heading='$heading[$i]',content='$content[$i]',image='$unique_name',cat_id='$catID'");
      
}
exit;

?>