Files
WrenchBoradWeb/www-api/public/svs/user/UploadManager.php
T
CHIEFSOFT\ameye 1a44832d3d Tracking flow
2023-06-04 16:06:27 -04:00

80 lines
2.6 KiB
PHP

<?php
function reciveUpload($in, $out){
$savePath = $in["system_primary_uploads"]; // WRENCHBOARD_UPLOAD_PATH; //"/opt/wrenchboard/TEST/";
$action = $in["action"];
$out["in_test_msg"]= "**-reciveUpload action = ". $action;
//DECIDE IF PARENT FOLDER IS PRESENT
if (!file_exists($savePath.'CONTRACTS')) {
mkdir($savePath.'CONTRACTS', 0777, true);
}
if (!file_exists($savePath.'PROFILE')) {
mkdir($savePath.'PROFILE', 0777, true);
}
if (!file_exists($savePath.'FAMILY')) {
mkdir($savePath.'FAMILY', 0777, true);
}
if (!file_exists($savePath.'JOBS')) {
mkdir($savePath.'JOBS', 0777, true);
}
$out["test_msg00"]= "loc 002";
switch ($action){
case WRENCHBOARD_PICTURE_FAMMEMBER:
// MAKE SURE FOLDER AS PER PROECESS IS AVILABLE
$thisContactFolder = $savePath.'FAMILY/'.$in["contract"];
if (!file_exists($thisContactFolder)) {
mkdir($thisContactFolder, 0777, true);
}
if (file_exists($thisContactFolder)) {
$tt_d = date('hisjmy');
$out["message"] = $tt_d."-".$in['file_name'];
$thisContactFolderFileName = $thisContactFolder.'/'.$out["message"];
$myfile = fopen($thisContactFolderFileName, "w") or die("Unable to open file!");
$file_data = base64_decode($in["file_data"]);
fwrite($myfile, $file_data);
fclose($myfile);
$out["call_backend"] = true; // flag ready to save data entry
}
break;
case WRENCHBOARD_CONTRACT_MESSAGE:
$out["test_msg01"]= "loc 001";
// MAKE SURE FOLDER AS PER PROECESS IS AVILABLE
$out["call_backend"] = false; // flag ready to save data entry
$thisContactFolder = $savePath.'CONTRACTS/'.$in["contract"];
if (!file_exists($thisContactFolder)) {
mkdir($thisContactFolder, 0777, true);
}
$out["test_msg02"]= "loc 002";
if (file_exists($thisContactFolder)) {
$tt_d = date('hisjmy');
$out["message"] = $tt_d."-".$in['file_name'];
$thisContactFolderFileName = $thisContactFolder.'/'.$out["message"];
$myfile = fopen($thisContactFolderFileName, "w") or die("Unable to open file!");
$file_data = base64_decode($in["file_data"]);
fwrite($myfile, $file_data);
fclose($myfile);
$out["call_backend"] = true; // flag ready to save data entry
}
break;
}
return $out;
}
?>