当前位置: 首页>>代码示例>>PHP>>正文


PHP Vtiger_Functions::validateImage方法代码示例

本文整理汇总了PHP中Vtiger_Functions::validateImage方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Functions::validateImage方法的具体用法?PHP Vtiger_Functions::validateImage怎么用?PHP Vtiger_Functions::validateImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vtiger_Functions的用法示例。


在下文中一共展示了Vtiger_Functions::validateImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Upload

 public function Upload(Vtiger_Request $request)
 {
     $templateId = $request->get('template_id');
     $newName = basename($_FILES['watermark']['name'][0]);
     $newName = explode('.', $newName);
     $newName = $templateId . '.' . end($newName);
     $targetDir = Settings_PDF_Module_Model::$uploadPath;
     $targetFile = $targetDir . $newName;
     $uploadOk = 1;
     $imageFileType = pathinfo($targetFile, PATHINFO_EXTENSION);
     // Check if image file is a actual image or fake image
     $check = getimagesize($_FILES['watermark']['tmp_name'][0]);
     if ($check !== false) {
         // file is an image
         $uploadOk = 1;
     } else {
         // File is not an image
         $uploadOk = 0;
     }
     // Check allowed upload file size
     if ($_FILES['watermark']['size'][0] > vglobal('upload_maxsize') && $uploadOk) {
         $uploadOk = 0;
     }
     $saveFile = Vtiger_Functions::validateImage(['type' => $_FILES['watermark']['type'][0], 'tmp_name' => $_FILES['watermark']['tmp_name'][0], 'size' => $_FILES['watermark']['size'][0]]);
     if ($saveFile == 'false') {
         $uploadOk = 0;
     }
     // Check if $uploadOk is set to 0 by an error
     if ($uploadOk == 1) {
         $db = PearDatabase::getInstance();
         $query = 'SELECT `watermark_image` FROM `a_yf_pdf` WHERE `pdfid` = ? LIMIT 1;';
         $result = $db->pquery($query, [$templateId]);
         $watermarkImage = $db->getSingleValue($result);
         if (file_exists($watermarkImage)) {
             unlink($watermarkImage);
         }
         // successful upload
         if (move_uploaded_file($_FILES['watermark']['tmp_name'][0], $targetFile)) {
             $query = 'UPDATE `a_yf_pdf` SET `watermark_image` = ? WHERE `pdfid` = ? LIMIT 1;';
             $db = $db->pquery($query, [$targetFile, $templateId]);
         }
     }
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:43,代码来源:Watermark.php

示例2: validateImageFile

/**
 * 	This function is used to check whether the attached file is a image file or not
 * 	@param string $file_details  - vtiger_files array which contains all the uploaded file details
 * 	return string $save_image - true or false. if the image can be uploaded then true will return otherwise false.
 */
function validateImageFile($file_details)
{
    return Vtiger_Functions::validateImage($file_details);
}
开发者ID:jmangarret,项目名称:vtigercrm,代码行数:9,代码来源:CommonUtils.php


注:本文中的Vtiger_Functions::validateImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。