Adapted DMSLib upload method to be accept field name from Controller

The fieldname represents the HTML uploadfile input name attribute, which
is given by the developer in the VIEW.

Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
Cris
2021-04-21 18:46:51 +02:00
committed by cris-technikum
parent 6dcb5e3a65
commit 7b485053d9
3 changed files with 8 additions and 8 deletions
@@ -223,7 +223,7 @@ class CreateAnrechnung extends Auth_Controller
);
// Upload document
return $this->dmslib->upload($dms, array('pdf'));
return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
}
}
@@ -316,6 +316,6 @@ class requestAnrechnung extends Auth_Controller
);
// Upload document
return $this->dmslib->upload($dms, array('pdf'));
return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
}
}
+6 -6
View File
@@ -5,8 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
class DmsLib extends FHC_Controller
{
const FILE_CONTENT_PROPERTY = 'file_content';
const FILE_INPUT_NAME = 'uploadfile'; // name of the HTML input tag containing the uploaded file
private $UPLOAD_PATH = DMS_PATH; // temporary directory to store the upload file
/**
@@ -123,19 +122,20 @@ class DmsLib extends FHC_Controller
return $result;
}
/**
* Uploads a document and saves it to DMS
* @param $dms DMS assoc array
* @param array $allowed_types Default: all. Param example: array(jpg, pdf)
* @param $field_name Name of the HTML uploadfile input name attribute
* @param array $allowed_types Default: all. Param example: array(jpg, pdf)
* @return array
*/
public function upload($dms, $allowed_types = array('*'))
public function upload($dms, $field_name, $allowed_types = array('*'))
{
// Init upload configs
$this->_loadUploadLibrary($allowed_types);
if (!$this->ci->upload->do_upload(DmsLib::FILE_INPUT_NAME))
if (!$this->ci->upload->do_upload($field_name))
{
return error($this->ci->upload->display_errors());
}