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


PHP upload::IsImageValid方法代码示例

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


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

示例1: imageUpload

 function imageUpload($argFILES, $argVarDirLocation, $varThumbnailWidth = '', $varThumbnailHeight = '', $varMediumWidth = '', $varMediumHeight = '')
 {
     $objUpload = new upload();
     $objCore = new Core();
     $objUpload->setMaxSize();
     $objUpload->setDirectory($argVarDirLocation);
     $varIsImage = $objUpload->IsImageValid($argFILES['type']);
     if ($varIsImage) {
         $varImageExists = 'yes';
     } else {
         $varImageExists = 'no';
     }
     if ($varImageExists == 'no') {
         $objCore->setErrorMsg(IMAGE_TYPE_ERROR);
         return false;
     }
     if ($varImageExists == 'yes') {
         $objUpload->setTmpName($argFILES['tmp_name']);
         if ($objUpload->userTmpName) {
             $objUpload->setFileSize($argFILES['size']);
             $objUpload->setFileType($argFILES['type']);
             $varRandomNumber = $this->generateRandomKey();
             $fileName = $varRandomNumber . '_' . strtolower($argFILES['name']);
             $fileName = str_replace(' ', '_', $fileName);
             $objUpload->setFileName($fileName);
             $objUpload->startCopy();
             if ($objUpload->isError()) {
                 $thumbnailName1 = '_thumb';
                 $objUpload->setThumbnailName($thumbnailName1);
                 $objUpload->createThumbnail();
                 if ($varThumbnailWidth == '' && $varThumbnailHeight == '') {
                     $objUpload->setThumbnailSize();
                 } else {
                     $objUpload->setThumbnailSize($varThumbnailWidth, $varThumbnailHeight);
                 }
                 $varFileName = $objUpload->userFileName;
                 $varExt = substr(strrchr($varFileName, "."), 1);
                 $varThumbFileNameNoExt = substr($varFileName, 0, -(strlen($varExt) + 1));
                 $varThumbFileName = $varThumbFileNameNoExt . 'thumb.' . $varExt;
                 $thumbnailName1 = '';
                 $objUpload->setThumbnailName($thumbnailName1);
                 $objUpload->createThumbnail();
                 if ($varMediumWidth == '' && $varMediumHeight == '') {
                     $objUpload->setThumbnailSize();
                 } else {
                     $objUpload->setThumbnailSize($varMediumWidth, $varMediumHeight);
                 }
                 return $varFileName;
             } else {
                 $objCore->setErrorMsg(ERROR_ON_UPLOAD);
                 return false;
             }
         }
     }
 }
开发者ID:saurabhs4,项目名称:niches,代码行数:55,代码来源:class.general.php

示例2: checkProductsValidation

 function checkProductsValidation($argArrPost)
 {
     $objValid = new Validate_fields();
     $objCore = new Core();
     $objValid->check_4html = true;
     $_SESSION['sessProducts'] = array();
     $objValid->add_text_field('Category', strip_tags($argArrPost['frmfkCategoryID']), 'text', 'y', 255);
     $objValid->add_text_field('Product Name', strip_tags($argArrPost['frmProductName']), 'text', 'y', 255);
     $objValid->add_text_field('Product Code', strip_tags($argArrPost['frmProductCode']), 'text', 'y', 255);
     $objValid->add_text_field('Product Description', strip_tags($argArrPost['frmProductDescription']), 'text', 'y');
     $objValid->add_text_field('Product Specifications', strip_tags($argArrPost['frmProductSpecifications']), 'text', 'y');
     $objValid->add_text_field('Product Set of Quantity', strip_tags($argArrPost['frmProductQuantity']), 'number', 'y');
     //$objValid->add_text_field('Product Quantity Available', strip_tags($argArrPost['frmProductQuantityAvailable']), 'number', 'y');
     $objValid->add_num_field('Product Cost', strip_tags($argArrPost['frmProductCost']), 'text', 'y');
     //$objValid->add_num_field('Product Total Cost', strip_tags($argArrPost['frmProductActualCost']), 'text', 'y');
     if ($objValid->validation()) {
         $errorMsgFirst = 'Please enter required fields!';
     } else {
         $errorMsg = $objValid->create_msg();
     }
     if (trim($argArrPost['frmProductCost']) != '') {
         if (!preg_match('/^[0-9]*\\.?[0-9]+$/', strip_tags(trim($argArrPost['frmProductCost'])))) {
             $errorMsg .= ERR_PRODUCT_PRICE_ERR;
         }
     }
     if (trim($argArrPost['frmProductActualCost']) != '') {
         if (!preg_match('/^[0-9]*\\.?[0-9]+$/', strip_tags(trim($argArrPost['frmProductActualCost'])))) {
             $errorMsg .= ERR_PRODUCT_RRP_ERR;
         }
     }
     if ($argArrPost['frmProductSeoFriendlyURL'] != '') {
         if (preg_match('/[^a-z-A-Z]/', $argArrPost['frmProductSeoFriendlyURL'])) {
             $errorMsg .= ERR_PRODUCTS_SEO_URL;
         }
     }
     if ($errorMsg) {
         $_SESSION['sessProducts'] = $argArrPost;
         $objCore->setErrorMsg($errorMsg);
         return true;
     } else {
         $arrProductCols = array('pkProductID');
         if ($argArrPost['frmProductID'] != '') {
             $varWhereProduct = 'ProductCode =\'' . $argArrPost['frmProductCode'] . '\' AND pkProductID !=\'' . $argArrPost['frmProductID'] . '\'';
         } else {
             $varWhereProduct = 'ProductCode =\'' . $argArrPost['frmProductCode'] . '\'';
         }
         $arrProductCodeList = $this->select(TABLE_PRODUCTS, $arrProductCols, $varWhereProduct);
         if ($arrProductCodeList != '') {
             $objCore->setErrorMsg(ERR_PRODUCT_CODE_EXISTS);
             $_SESSION['sessProducts'] = $argArrPost;
             return true;
         }
         //check the number of featured count
         if ($argArrPost['frmProductID'] != '') {
             $varWhereCondition = 'AND ProductIsFeatured = \'' . $argArrPost['frmProductIsFeatured'] . '\' AND pkProductID != \'' . $argArrPost['frmProductID'] . '\'';
         } else {
             $varWhereCondition = 'AND ProductIsFeatured = \'' . $argArrPost['frmProductIsFeatured'] . '\'';
         }
         $varColumn = 'pkProductID';
         $varResultCount = $this->getNumRows(TABLE_PRODUCTS, $varColumn, $varWhereCondition);
         $argArrPost['frmProductIsFeatured'];
         if ($varResultCount >= MAX_FEATURED_COUNT && $argArrPost['frmProductIsFeatured'] == 'Yes') {
             $objCore->setErrorMsg(ERR_FEATURED_PRODUCT);
             $_SESSION['sessProducts'] = $argArrPost;
             return true;
         }
         //check for valid image type
         $objUpload = new upload();
         if ($_FILES['frmProductImage']['name'] != '') {
             $varIsImage = $objUpload->IsImageValid($_FILES['frmProductImage']['type']);
             if (!$varIsImage) {
                 $varErrorMsg = IMAGE_TYPE_ERROR;
                 $objCore->setErrorMsg(IMAGE_TYPE_ERROR);
                 $_SESSION['sessProducts'] = $argArrPost;
                 return true;
             }
             //chekc for image size
             $varMaxFileSize = MAX_UPLOAD_SIZE;
             $varFileSize = $_FILES['frmProductImage']['size'];
             if ($varFileSize > $varMaxFileSize) {
                 $varErrorMsg = FILE_SIZE_ERROR;
                 $objCore->setErrorMsg($varErrorMsg);
                 $_SESSION['sessProducts'] = $argArrPost;
                 return true;
             }
             //end chekc for image size
         }
         return false;
     }
 }
开发者ID:saurabhs4,项目名称:demoshop,代码行数:90,代码来源:class.product.php


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