<?php

	if(isset($_REQUEST['upload_file'])){
		echo "<pre>";
		print_r($_REQUEST);
		print_r($_FILES);
		echo "</pre>";

		$target_folder = "data_upload/";
		
		$file_extension = strtolower(pathinfo($_FILES['select_file']['name'],PATHINFO_EXTENSION));
		
		$file_size = $_FILES['select_file']['size'];
		$confirmation = 1;
		
		$miliseconds = strtotime(date('d-m-Y h:i:s')) * 1000;
		
		$file_path = $target_folder.'file_upload_'.$miliseconds.'.'.$file_extension;
		
		if(($file_extension != 'jpg') || ($file_extension != 'png') || ($file_extension != 'jpeg')){
			$confirmation = 0;
		}
		
		if($file_size <= 50000){
			$confirmation = 1;
		}
		else{
			$confirmation = 0;
		}
		
		if(file_exists($file_path)){
			$confirmation = 0;
		}
		
		if($confirmation == 0){
			echo "Error occurred during file upload.";
		}
		else{
			$result = move_uploaded_file($_FILES['select_file']['tmp_name'],$file_path);
			if($result){
				echo "Your file has been successfully uploaded.";
			}
			else{
				echo "Some technical error occurred.";
			}
		}
	}

?>