From 33bc6f6ce093666c5b369cd90b12fb5e4225af5c Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 27 Apr 2017 16:50:19 +0200 Subject: [PATCH] WIP of background & logo image upload into instance dir --- admin/inc/class.admin_config.inc.php | 31 ++++++++++++++++++++++++++++ admin/templates/default/config.xet | 16 +++++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/admin/inc/class.admin_config.inc.php b/admin/inc/class.admin_config.inc.php index b3d6102c96..e07f826919 100644 --- a/admin/inc/class.admin_config.inc.php +++ b/admin/inc/class.admin_config.inc.php @@ -19,6 +19,37 @@ class admin_config { var $public_functions = array('index' => True); + /** + * Upload function to store files into instance files_dir + * + * @param type $file file info array + * @param type $dir directory to store file + * + */ + function ajax_upload ($file, $dir = null) + { + $files_dir = $dir ? $dir : $GLOBALS['egw_info']['server']['files_dir'].'/images'; + $success = false; + $response = Api\Json\Response::get(); + if (is_array($file) && is_writable(dirname($files_dir))) + { + if (!is_dir($files_dir)) mkdir ($files_dir); + $tmp_file = array_keys($file); + $destination = $files_dir.'/'.$file[$tmp_file[0]]['name']; + $success = rename($GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp_file[0],$destination); + } + if ($success) + { + $response->data(array( + 'path' => $destination + )); + } + else + { + $response->error(lang('Failed to upload %1',$destination)); + } + } + function index($_content=null) { if (is_array($_content)) diff --git a/admin/templates/default/config.xet b/admin/templates/default/config.xet index bd92e644f0..dd3058d971 100644 --- a/admin/templates/default/config.xet +++ b/admin/templates/default/config.xet @@ -52,23 +52,29 @@ - + + + + - + - + - + + + + - +