diff --git a/www-api/app/Models/UploadManager.php b/www-api/app/Models/UploadManager.php index 5a5f63ec..f36ebbf6 100644 --- a/www-api/app/Models/UploadManager.php +++ b/www-api/app/Models/UploadManager.php @@ -78,6 +78,43 @@ class UploadManager extends Model break; case WRENCHBOARD_PICTURE_FAMMEMBER: + if ( trim($in["uid"]) == '' && trim($in["family_uid"]) == ''){ + $out["error_msg"] = "invalid_upload_call"; + $out["call_backend"] = false; // something went bad + return -1; + } + // MAKE SURE FOLDER AS PER PROCESS IS AVAILABLE + $thisProfileFolder = $this->savePath.'PROFILE/'.$in["uid"]; + if (!file_exists($thisProfileFolder)) { + mkdir($thisProfileFolder, 0777, true); + } + if (!file_exists($thisProfileFolder."/FAMILY")) { + mkdir($thisProfileFolder."/FAMILY", 0777, true); + } + + if (!file_exists($thisProfileFolder."/FAMILY/".$in["family_uid"] )) { + mkdir($thisProfileFolder."/FAMILY/".$in["family_uid"], 0777, true); + } + + + $myFilesFolder = $thisProfileFolder."/FAMILY/".$in["family_uid"]; + + if (file_exists($myFilesFolder)) { + $out["message"] = "completed"; + $pieces = explode(".", $in['file_name']); + $in['profile'] = "profile." . $pieces[1]; + $myFilesFolderFileName = $myFilesFolder . '/' . $in['profile']; + $myfile = fopen($myFilesFolderFileName, "w") or die("Unable to open file!"); + $file_data = base64_decode($in["file_data"]); + fwrite($myfile, $file_data); + fclose($myfile); + $out["call_backend"] = false; // flag ready to save data entry + $data['file_uid'] = $in["uid"]; + $data['profile'] = $in["profile"]; + $out['upload_result'] = $this->specififBackendCall(WRENCHBOARD_PICTURE_FAMMEMBER, $data); + } + break; + case WRENCHBOARD_RESOURCE_MYFILES: if ( trim($in["uid"]) == ''){