55ok
| Direktori : /home/bestphotography/public_html/Admin/ |
| Current File : /home/bestphotography/public_html/Admin/insertimage.php |
<?php
ob_start();
session_start();
include "config.php";
// Check if the user is logged in, if not then redirect him to login page
if(!isset($_SESSION["login"]) && $_SESSION["login"] !== true){
header("location: index.php");
exit;
}
date_default_timezone_set('Asia/Kolkata');
$images=($_FILES['images']['name']);
$img="";
if(isset($_FILES['images'])){
//$flag="0";
$name_array = $_FILES['images']['name'];
$tmp_name_array = $_FILES['images']['tmp_name'];
// Number of files
$count_tmp_name_array = count($tmp_name_array);
// We define the static final name for uploaded files (in the loop we will add an number to the end)
for($i = 0; $i < $count_tmp_name_array; $i++){
// Get extension of current file
$extension = pathinfo($name_array[$i] , PATHINFO_EXTENSION);
$type = "album";
$fname = $_POST["gallery_name"];
$uploading_time = date("d-m-Y H:i:s");
$pimg = $type.'_'.$fname.'_'.$i.'_'.$uploading_time;
$img.=$type.'_'.$fname.'_'.$i.'_'.$uploading_time.'.'.$extension."|";
// Pay attention to $static_final_name
if(move_uploaded_file($tmp_name_array[$i], "../assets/img/portfolio/detail/".$pimg.".".$extension)){
//echo $name_array[$i]." upload is complete<br>";
} else {
//echo "move_uploaded_file function failed for ".$name_array[$i]."<br>";
}
}
$images=rtrim($img,"|");
}
mysqli_query($conn,"set names 'utf8'");
$pid=$_GET['pid'];
$delid=$_GET['delid'];
//echo "$images";
$query1 = "select * from gallery where gallery_id='$pid'";
mysqli_query($conn, $query1) or die('Error querying database.');
$result = mysqli_query($conn, $query1);
$query2=mysqli_fetch_array($result);
{
$preimg = $query2['images'];
$test1 = $preimg.$images."|";
$sql="update gallery set images='$test1' where gallery_id='$pid'";
}
if (!mysqli_query($conn,$sql))
{
die('Error: ' . mysqli_error($conn));
}
mysqli_close($conn);
header("location:imgupdate.php?gid=".$pid."");
?>