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


PHP Validation::extension方法代码示例

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


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

示例1: extension

 /**
  * Checks if extension is (not) one of given extensions
  *
  * @param string $check Extension to check (without leading dot)
  * @param mixed $deny True or * blocks any extension,
  * 	an array containing extensions (without a leading dot) selectively blocks,
  * 	false blocks no extension
  * @param mixed $allow True or * allows any extension,
  * 	an array containing extensions (without leading dot) selectively allows,
  * 	false allows no extension
  * @return boolean
  */
 function extension($check, $deny = false, $allow = true)
 {
     if (!is_string($check) || !preg_match('/^[\\w0-9]+(\\.[\\w0-9]+)?$/', $check)) {
         return false;
     }
     list($deny, $allow) = self::_normalize($deny, $allow);
     if ($deny === true || is_array($deny) && Validation::extension($check, $deny)) {
         return false;
     }
     if ($allow !== true && (is_array($allow) && !Validation::extension($check, $allow))) {
         return false;
     }
     return true;
 }
开发者ID:rcaravita,项目名称:jodeljodel,代码行数:26,代码来源:media_validation.php

示例2: validateName

 function validateName($file = array(), $ext = array())
 {
     $err = array();
     $i = 0;
     foreach ($file as $file) {
         $i++;
         if (!empty($file['name'])) {
             if (!Validation::extension($file['name'], $ext)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:koprals,项目名称:coda-gosales-hsbc,代码行数:14,代码来源:Setting.php

示例3: validFile

 function validFile($check, $settings)
 {
     $_default = array('required' => false, 'extensions' => array('jpg', 'jpeg', 'gif', 'png'));
     $_settings = array_merge($_default, ife(is_array($settings), $settings, array()));
     // Remove first level of Array
     $_check = array_shift($check);
     if ($_settings['required'] == false && $_check['size'] == 0) {
         return true;
     }
     // No file uploaded.
     if ($_settings['required'] && $_check['size'] == 0) {
         return false;
     }
     // Check for Basic PHP file errors.
     if ($_check['error'] !== 0) {
         return false;
     }
     // Use PHPs own file validation method.
     if (is_uploaded_file($_check['tmp_name']) == false) {
         return false;
     }
     // Valid extension
     return Validation::extension($_check, $_settings['extensions']);
 }
开发者ID:roae,项目名称:hello-world,代码行数:24,代码来源:tiny_image.php

示例4: testExtension

 /**
  * testExtension method
  *
  * @return void
  */
 public function testExtension()
 {
     $this->assertTrue(Validation::extension('extension.jpeg'));
     $this->assertTrue(Validation::extension('extension.JPEG'));
     $this->assertTrue(Validation::extension('extension.gif'));
     $this->assertTrue(Validation::extension('extension.GIF'));
     $this->assertTrue(Validation::extension('extension.png'));
     $this->assertTrue(Validation::extension('extension.jpg'));
     $this->assertTrue(Validation::extension('extension.JPG'));
     $this->assertFalse(Validation::extension('noextension'));
     $this->assertTrue(Validation::extension('extension.pdf', array('PDF')));
     $this->assertFalse(Validation::extension('extension.jpg', array('GIF')));
     $this->assertTrue(Validation::extension(array('extension.JPG', 'extension.gif', 'extension.png')));
     $this->assertTrue(Validation::extension(array('file' => array('name' => 'file.jpg'))));
     $this->assertTrue(Validation::extension(array('file1' => array('name' => 'file.jpg'), 'file2' => array('name' => 'file.jpg'), 'file3' => array('name' => 'file.jpg'))));
     $this->assertFalse(Validation::extension(array('file1' => array('name' => 'file.jpg'), 'file2' => array('name' => 'file.jpg'), 'file3' => array('name' => 'file.jpg')), array('gif')));
     $this->assertFalse(Validation::extension(array('noextension', 'extension.JPG', 'extension.gif', 'extension.png')));
     $this->assertFalse(Validation::extension(array('extension.pdf', 'extension.JPG', 'extension.gif', 'extension.png')));
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:24,代码来源:ValidationTest.php

示例5: extension

 /**
  * Check that value has a valid file extension.
  *
  * @param mixed $check Value to check
  * @param array $extensions file extenstions to allow
  * @return boolean Success
  * @access public
  */
 function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg'))
 {
     if (is_array($check)) {
         foreach ($check as $value) {
             if (Validation::extension($value, $extensions) === false) {
                 return false;
             }
             return true;
         }
     }
     $extension = strtolower(array_pop(explode('.', $check)));
     if (in_array($extension, array_map('strtolower', $extensions))) {
         return true;
     }
     return false;
 }
开发者ID:javierm,项目名称:wildflower,代码行数:24,代码来源:validation.php

示例6: extension

 /**
  * Check that value has a valid file extension.
  *
  * @param mixed $check Value to check
  * @param array $extensions file extenstions to allow
  * @return boolean Success
  * @access public
  */
 function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg'))
 {
     if (is_array($check)) {
         return Validation::extension(array_shift($check), $extensions);
     }
     $extension = strtolower(array_pop(explode('.', $check)));
     foreach ($extensions as $value) {
         if ($extension == strtolower($value)) {
             return true;
         }
     }
     return false;
 }
开发者ID:michaelTadeu,项目名称:nutriware,代码行数:21,代码来源:validation.php


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