MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b2432/valphp.dailyroll.org/
File Upload :
Current < : //hermes/sb_web/b2432/valphp.dailyroll.org/UploadToServer.php

<?php  
require_once 'constants/constants.php';
$file_path = DIR_VEDIOS; 
$eventlog = EVENTLOG;
	function event_log($text){
	if(EVENTLOG == Y){
		$text=$uid."\t".$text;
		$file = "logs"."/".APP_NAME.date("Y-m-d").".log";
//$file = "logs/dailyroll".date("Y-m-d").".log";
		error_log(date("[Y-m-d H:i:s]")."\t[INFO][".basename(__FILE__)."]\t".$text."\r\n", 3, $file);
	}		
	}  
function getDatePath(){
	//Year in YYYY format.
	$year = date("Y");
	 
	//Month in mm format, with leading zeros.
	 $month = date("m");
	 
	//Day in dd format, with leading zeros.
	 $day = date("d");
	 
	//The folder path for our file should be YYYY/MM/DD
	$directory = "$year/$month/$day/";
	return $directory;
}
$file= basename($_FILES['uploaded_file']['name']);
 //echo $file= '5b3546677c0140.52919308-29-06-2018-03:16:45-AM.jpg';

if((strpos($file, '.png') !== false) || (strpos($file, '.jpg') !== false)){

$ret = explode('-', $file);
$userid=$ret[0];
	 $datedir=getDatePath();
	
	  $file_path  = DIR_VEDIOS."".$userid."/".$datedir;
	
	if(!is_dir($file_path)){
		//echo"Create our directoryeach";
		mkdir($file_path, 0777, true);
    }
	
}else{
	$file_path=DIR_VEDIOS;
}	
	$file_path = $file_path .$file;
	json_encode($file_path);
	if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)){
	   $res=$file_path;
	   echo json_encode($res);
	    event_log(json_encode($res));
      
	}else{
	    $res="fail";
	    echo json_encode($res);
		 event_log(json_encode($res));
		
	}

 ?>