<?php
	Log::write("import ocr upload");
	$fn = $_REQUEST['n'] ;
	$docUploaded = false ;
	$limitsize = 5000 * 1024;	//5mb
	if (!empty($_FILES)) {
		$size = $_FILES[$fn]['size'];
		if($size > 0){
			//if ($size < $limitsize) {
				$docfile =  basename($_FILES[$fn]['name']);
				$pi = pathinfo($docfile);
				$ext = $pi['extension'];
				$exts = array("zip") ;
				if (Util::validFileExt($ext,$exts)) {
					$tmpfile = "ocr_template_export." . $ext ;
					$uploadfile = PATH_PORTAL_TEMP . $tmpfile ;
					Log::write($uploadfile);
					if (move_uploaded_file($_FILES[$fn]['tmp_name'], $uploadfile)) {
						$docUploaded = 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 50KB." ;
			//}
		} else {
			$err = "Missing upload file.";
		}
	} else {
		$err = "No upload file found." ;
	}
	if($docUploaded){
		echo Status::Ok . "|" . $docfile . "|" . $tmpfile;
	}else{
		echo Status::Error . "|" . $err ;
	}
	
?>