Ignore:
Timestamp:
Apr 30, 2012, 1:58:44 AM (12 years ago)
Author:
plg
Message:

feature 2626: ability to upload a new watermark

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/configuration_watermark_process.inc.php

    r14513 r14546  
    2929$errors = array();
    3030$pwatermark = $_POST['w'];
     31
     32// step 0 - manage upload if any
     33if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_name']))
     34{
     35  list($width, $height, $type) = getimagesize($_FILES['watermarkImage']['tmp_name']);
     36  if (IMAGETYPE_PNG != $type)
     37  {
     38    $errors['watermarkImage'] = 'PNG';
     39  }
     40  else
     41  {
     42    $upload_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks';
     43
     44    include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
     45    prepare_directory($upload_dir);
     46
     47    $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
     48    $file_path = $upload_dir.'/'.$new_name;
     49 
     50    move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path);
     51   
     52    $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
     53  }
     54}
    3155
    3256// step 1 - sanitize HTML input
Note: See TracChangeset for help on using the changeset viewer.