/** * saveFile */ public function saveFile($file_single, $survey_entry_id, $question_id, $answer_id) { // find survey_id by $survey_entry_id require_once 'models/education/education_survey_entry.php'; $Survey_Entry = new education_survey_entry(); $survey_entry_data = $Survey_Entry->detail($survey_entry_id); $survey_id = $survey_entry_data['survey_id']; /** * add prefix to filename (rename) */ $file_single['name'] = $this->getFilenameToSave($file_single['name'], $survey_entry_id, $question_id, $answer_id); /** * file */ require_once 'models/common/common_file.php'; //getSingleUpload could be a static method $CommonFile = new common_file(); $upload = $CommonFile->getSingleUpload($file_single, "var/surveys/{$survey_id}/"); /** * array indicated the same file name already exists in the var/tmp/ folder * this should never happen as we have entry id in filename */ if (is_array($upload)) { $attachment_saved_file = ONXSHOP_PROJECT_DIR . $upload['temp_file']; } else { $attachment_saved_file = ONXSHOP_PROJECT_DIR . $upload; } /** * check if file exists and than return filename */ if (file_exists($attachment_saved_file)) { $attachment_info = $CommonFile->getFileInfo($attachment_saved_file); return $attachment_info['filename']; } }