From a129632a26ef081f54718ef04e29a1267424e798 Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 29 Apr 2012 23:58:44 +0000 Subject: feature 2626: ability to upload a new watermark git-svn-id: http://piwigo.org/svn/trunk@14546 68402e56-0260-453c-a942-63ccdbb3a9ee --- .../configuration_watermark_process.inc.php | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'admin/include') diff --git a/admin/include/configuration_watermark_process.inc.php b/admin/include/configuration_watermark_process.inc.php index 2beaa19b1..676056300 100644 --- a/admin/include/configuration_watermark_process.inc.php +++ b/admin/include/configuration_watermark_process.inc.php @@ -29,6 +29,30 @@ if( !defined("PHPWG_ROOT_PATH") ) $errors = array(); $pwatermark = $_POST['w']; +// step 0 - manage upload if any +if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_name'])) +{ + list($width, $height, $type) = getimagesize($_FILES['watermarkImage']['tmp_name']); + if (IMAGETYPE_PNG != $type) + { + $errors['watermarkImage'] = 'PNG'; + } + else + { + $upload_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks'; + + include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); + prepare_directory($upload_dir); + + $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png'; + $file_path = $upload_dir.'/'.$new_name; + + move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path); + + $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH)); + } +} + // step 1 - sanitize HTML input switch ($pwatermark['position']) { -- cgit v1.2.3