<?php
	$fn = $_REQUEST['n'] ;
	$id = $_REQUEST['i'] ;
	$serviceId = $_REQUEST['sid'] ;	
	$imgUploaded = false ;
	$limitsize = 3 * 1000 * 1024;	//3mb
	if (!empty($_FILES)) {
		$size = $_FILES[$fn]['size'];
		if($size > 0){
			if ($size < $limitsize) {
				$imgfile =  basename($_FILES[$fn]['name']);
				$pi = pathinfo($imgfile);
				$ext = $pi['extension'];
				$exts = array("png","jpg","jpeg") ;
				if (Util::validFileExt($ext,$exts)) { 
					$uploadfile = PATH_SERVICE."tmp/" . $imgfile ;
					if (move_uploaded_file($_FILES[$fn]['tmp_name'], $uploadfile)) {
						$imgUploaded = true ;
						$err = "" ;
					} else {
						$err = "Error in processing uploaded file." ;
					}
				} else {
					$err = "Unsupported upload file type." ;
				}
			} else {
				$err = "Upload file over limit. Upload file size must be less than 1 MB." ;
			}
		} else {
			$err = "Missing upload file.";
		}
	} else {
		$err = "No upload file found." ;
	}
	if($imgUploaded){
		echo Status::Ok."|".$uploadfile."|".basename($uploadfile)."|".$id ."|".$serviceId;
	}else{
		echo Status::Error . "|" . $err ;
	}
	
?>