<?php
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj=new my_class();
// ============


session_start();
if(isset($_FILES["file"]["type"]))
{
	$return=array();
$validextensions = array("jpeg", "jpg", "png");
$temporary = explode(".", $_FILES["file"]["name"]);
$file_extension = end($temporary);
if ((($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/jpeg")
) && ($_FILES["file"]["size"] < 10000000)//Approx. 100kb files can be uploaded.
&& in_array($file_extension, $validextensions)) {
if ($_FILES["file"]["error"] > 0)
{
$return[]="Error";
$return[]=$_FILES["file"]["error"];

}
else
{
	$file_extension='jpg';
$new_file_name=date('Ymdhis').rand(1000, 999999).".".$file_extension;
$sourcePath = $_FILES['file']['tmp_name']; // Storing source path of the file in a variable
$targetPath = "../../asset/custom/upload/employee/".$new_file_name; // Target path where file is to be stored
move_uploaded_file($sourcePath,$targetPath) ; // Moving Uploaded file

	/* $form_data1['_photo_location']=$new_file_name;
	$form_data1['_pid']='0';
	$form_data1['_type']='0';
	$form_data1['_entry_by']=$_SESSION['LOGIN_USERID'];
	$form_data1['_entry_date']=date("Y:m:d h:i:s");
		//inserting in _int_institute_setup
		$table_name='_pf_photo';
		
		$entry1=$obj->Insert_Data($table_name, $form_data1); */
		$return['status']="Success";
$return['id']='';
$return['image']=$new_file_name;
$return['source']=$targetPath;
}
}
else
{
	$return['status']="Error";
$return['message']="Invalid file Size or Type";

}
echo json_encode($return);
}


?>