file upload
This commit is contained in:
@@ -472,8 +472,10 @@ class WrenchApi extends BaseController
|
||||
//$fl_in=[];
|
||||
$raw_json = file_get_contents('php://input');
|
||||
$raw_array = json_decode($raw_json, true);
|
||||
$raw_array["call_backend"] = $call_backend;
|
||||
$ll = ( new \App\Models\UploadManager() )->reciveUpload($raw_array, $local_out);
|
||||
|
||||
$raw_array["call_backend"] = $local_out["call_backend"];
|
||||
$raw_array["message"] = $local_out["message"];
|
||||
}
|
||||
if (isset($_FILES) && is_array($_FILES) && count($_FILES)>0) {
|
||||
$raw_array = array_merge($_POST,$_FILES);
|
||||
|
||||
@@ -9,6 +9,9 @@ class UploadManager extends Model
|
||||
public $savePath ="/opt/wrenchboard/TEST/"; ////10.0.0.40/wrenchboard/TEST/";
|
||||
public function reciveUpload($in,$out){
|
||||
|
||||
$action = $in["action"];
|
||||
|
||||
|
||||
//DECIDE IF PARENT FOLDER IS PRESENT
|
||||
if (!file_exists($this->savePath.'CONTRACTS')) {
|
||||
mkdir($this->savePath.'CONTRACTS', 0777, true);
|
||||
@@ -22,20 +25,29 @@ class UploadManager extends Model
|
||||
mkdir($this->savePath.'JOBS', 0777, true);
|
||||
}
|
||||
|
||||
// MAKE SURE FOLDER AS PER PROECESS IS AVILABLE
|
||||
$thisContactFolder = $this->savePath.'CONTRACTS/'.$in["contract"];
|
||||
if (!file_exists($thisContactFolder)) {
|
||||
mkdir($thisContactFolder, 0777, true);
|
||||
switch ($action){
|
||||
|
||||
case WRENCHBOARD_CONTRACT_MESSAGE:
|
||||
// MAKE SURE FOLDER AS PER PROECESS IS AVILABLE
|
||||
$thisContactFolder = $this->savePath.'CONTRACTS/'.$in["contract"];
|
||||
if (!file_exists($thisContactFolder)) {
|
||||
mkdir($thisContactFolder, 0777, true);
|
||||
}
|
||||
|
||||
if (file_exists($thisContactFolder)) {
|
||||
$out["message"] = rand(100,999)."-".$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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($thisContactFolder)) {
|
||||
$thisContactFolderFileName = $thisContactFolder.'/'.rand(100,999)."-".$in['file_name'];
|
||||
$myfile = fopen($thisContactFolderFileName, "w") or die("Unable to open file!");
|
||||
fwrite($myfile, $in["file_data"]);
|
||||
fclose($myfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -43,6 +55,9 @@ class UploadManager extends Model
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* 'message' => string 'Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero' (length=127)
|
||||
'msg_type' => string
|
||||
* 'member_id' => int 1
|
||||
'sessionid' => string '9739747631A235F6C316F1BC8C7D823D873B5DAEB7922750AECFE1E887E4D3A9' (length=64)
|
||||
'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36)
|
||||
|
||||
Reference in New Issue
Block a user