GIF89a php
Current File : /home/hencockfreshchic/public_html/erp/savebanner.php
<?php
ob_start();
ini_set('error_reporting', E_STRICT);
include("connect.php");
mysqli_set_charset($conn,'utf8');
date_default_timezone_set('Asia/Kolkata');

$type=$_POST['type'];

		$temp = explode(".",$_FILES["image"]["name"]);
		$target_dir='image/'.date('Ymdhis').'.'.end($temp);

		if (file_exists($target_dir)) {
		   echo '<script>alert("Image already exist | try another file");</script>';
		   echo '<script>window.location.href="homeBanner.php";</script>';
		}
		else
		{
			$FileType = strtolower(pathinfo($target_dir,PATHINFO_EXTENSION));
			if($FileType != "png" && $FileType != "jpg" && $FileType != "jpeg" && $FileType != "gif")
			{
			// file format not supportedonly images allows
			 echo '<script>alert("Invalid image format");</script>';
		 	echo '<script>window.location.href="homeBanner.php";</script>';
			
			}
			else
			{
				move_uploaded_file($_FILES["image"]["tmp_name"],$target_dir);
				$sql="INSERT INTO `homebanner`(`image`,`type`) VALUES ('".$target_dir."','".$type."')";
				$rs=mysqli_query($conn,$sql);
				if($rs>0)
				{
					echo '<script>window.location.href="homeBanner.php";</script>';
				}
				else
				{
					echo '<script>alert("Cant save data.");</script>';
					echo '<script>window.location.href="homeBanner.php";</script>';
				}
			}
		}

?>