58 lines
2.2 KiB
PHP
58 lines
2.2 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class UploadManager extends Model
|
|
{
|
|
|
|
public $savePath ="/opt/wrenchboard/TEST/"; ////10.0.0.40/wrenchboard/TEST/";
|
|
public function reciveUpload($in,$out){
|
|
|
|
//DECIDE IF PARENT FOLDER IS PRESENT
|
|
if (!file_exists($this->savePath.'CONTRACTS')) {
|
|
mkdir($this->savePath.'CONTRACTS', 0777, true);
|
|
}
|
|
|
|
if (!file_exists($this->savePath.'PROFILE')) {
|
|
mkdir($this->savePath.'PROFILE', 0777, true);
|
|
}
|
|
|
|
if (!file_exists($this->savePath.'JOBS')) {
|
|
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);
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* 'member_id' => int 1
|
|
'sessionid' => string '9739747631A235F6C316F1BC8C7D823D873B5DAEB7922750AECFE1E887E4D3A9' (length=64)
|
|
'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36)
|
|
'file_name' => string 'international-user.svg' (length=22)
|
|
'file_size' => int 1421
|
|
'file_type' => string 'image/svg+xml' (length=13)
|
|
'file_data' => string 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCIgaWQ9IkludGVybmF0aW9uYWxVc2VyIj48cGF0aCBmaWxsPSIjZTZlN2Y5IiBkPSJNMzguNSAzMS4xYzIuMS0xLjEgMy45LTIuNSA1LjQtNC40aC0zLjJjLS42IDEuNi0xLjMgMy4xLTIuMiA0LjR6bS01LjggMS40YzItLjcgMy43LTIuOCA0LjktNS44aC00Ljl2NS44em04LjgtOC42aDQuMmMuOS0xLjggMS41LTMuNyAxLjctNS44aC01LjFjLS4xIDItLjQgNC0uOCA1Ljh6bTIuNC0xNy4zYy0xLjUtMS44LTMuMy0zLjMtNS40LTQuNC44IDEuMiAxLjYgMi43IDIuMiA0LjRoMy4yem0tNS4zIDIuOWgtNS45djUuOGg2LjdjLS4xLTIuMS0uNC00LjEtLjgtNS44em0zLjcgNS44'... (length=1896)
|
|
'msg_type' => string 'FILE' (length=4)
|
|
'contract' => string '49BWBRW738' (length=10)
|
|
'action' => int 14010
|
|
/var/www/html/public/wrenchboard/uploads.php:48:null
|
|
*/
|