コード例 #1
0
ファイル: channel.php プロジェクト: tleonard2/durablegbFeb
/**
 * Function to upload profile or cover images
 * @param array $imageParam
 * @return void
 */
function imageUploadHelper($imageParam)
{
    $userID = $imageParam['userID'];
    $ieBrowser = $imageParam['ieBrowser'];
    $requestUserID = $imageParam['requestUserID'];
    $uploadType = $imageParam['uploadType'];
    $imageType = $imageParam['imageType'];
    if ($imageType == 'image/jpeg') {
        $extension = 'jpeg';
    } elseif ($imageType == 'image/png') {
        $extension = 'png';
    } elseif ($imageType == 'image/gif') {
        $extension = 'gif';
    } else {
        $extension = '';
        echo json_encode(array('errormsg' => 'true', 'errmsg' => 'Invalid type'));
        exitAction('');
    }
    $imageName = $uploadType . $userID . time() . '.' . $extension;
    $targetPath = APPTHA_VGALLERY_BASEDIR . "/images/channel/banner/" . $imageName;
    $imageDetails = getimagesize($_FILES['images']['tmp_name']);
    $imageWidth = $imageDetails[0];
    $imageHeight = $imageDetails[1];
    if ($imageWidth < 1000 || $imageHeight < 700) {
        if (empty($ieBrowser)) {
            echo json_encode(array('errormsg' => 'true', 'errmsg' => 'Image must be greater than or equal to 1024x700 pixels'));
            exitAction('');
        } else {
            echo json_encode(array('errormsg' => 'true', 'errmsg' => 'Image must be greater than or equal to 1024x700 pixels'));
            exitAction('');
        }
    }
    if (move_uploaded_file($_FILES['images']["tmp_name"], $targetPath)) {
        $_SESSION['imageName'] = $imageName;
        $_SESSION['user_id'] = $requestUserID;
        $_SESSION['imageUploadType'] = $uploadType;
        $_SESSION['imageExtension'] = $extension;
        $result = json_encode(array('imageName' => $imageName, 'imageWidth' => $imageWidth, 'imageHeight' => $imageHeight, 'errormsg' => 'false', 'uploadType' => $uploadType));
    } else {
        echo __('Not Moved', APPTHA_VGALLERY);
        exitAction('');
    }
    if (!empty($ieBrowser)) {
        croppingCoverImage($userID);
    } else {
        echo $result;
        exitAction('');
    }
}
コード例 #2
0
 /**
  * Function to call croppingCoverImage method to crop profile or cover images.
  * This function crop profile images with user required width and height.
  * This function crop cover images with user required width and height.
  * @param   int  $userID   user id
  * @return  void
  */
 public function croppingCoverImageController($userID)
 {
     croppingCoverImage($userID);
 }