Files
WrenchBoradWeb/www-api/public/svs/user/UploadManager.php
T
CHIEFSOFT\ameye 2552160a71 Upload engine
2023-06-03 16:42:11 -04:00

78 lines
2.4 KiB
PHP

<?php
function reciveUpload($in, $out){
$savePath = WRENCHBOARD_UPLOAD_PATH; //"/opt/wrenchboard/TEST/";
$action = $in["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);
}
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:
// 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);
}
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;
}
?>