Support file upload in extra vars

This commit is contained in:
Kijin Sung 2024-10-09 00:03:16 +09:00
parent d45c116c56
commit 50274a7f9b
2 changed files with 97 additions and 5 deletions

View file

@ -4,6 +4,7 @@ namespace Rhymix\Modules\Extravar\Models;
use BaseObject;
use Context;
use FileController;
use ModuleModel;
use Rhymix\Framework\DateTime;
use Rhymix\Framework\i18n;
@ -275,6 +276,25 @@ class Value
return null;
}
/**
* Upload a file.
*
* @param array $file
* @param int $target_srl
* @param string $target_type
* @return BaseObject
*/
public function uploadFile(array $file, int $target_srl, string $target_type): BaseObject
{
$oFileController = FileController::getInstance();
$output = $oFileController->insertFile($file, $this->module_srl, $target_srl);
if ($output->toBool())
{
$oFileController->setFilesValid($target_srl, "ev:$target_type", $output->get('file_srl'));
}
return $output;
}
/**
* Get the next temporary ID.
*