本文整理汇总了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;
}
}
}
}
示例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;
}
}