Determines if the temporary file has a valid extension
An empty string in the validation map indicates files without an extension.
@return boolean
519118
public function isValidExtension()
    {
        return !count($this->allowedExtensions)
            || in_array($this->getFileExtension(), $this->allowedExtensions, true);
    }
1279009
def has_extensions(self, *exts):
        """"""
        file_ext = splitext(self.filename)[1]
        file_ext = file_ext.lower()

        for e in exts:
            if file_ext == e:
                return True
        return False
628965
public function isValidUpload()
    {
        // Check file upload
        if ($this->tmpFile['error'] === UPLOAD_ERR_NO_FILE) {
            return false;
        }

        // Note that some "max file size" errors leave "tmp_name" empty, so don't fail on this.
        if (empty($this->tmpFile['tmp_name'])) {
            return true;
        }

        // Check if file is valid uploaded (with exception for unit testing)
        $useUploadedFile = $this->config()->get('use_is_uploaded_file');
        if ($useUploadedFile && !is_uploaded_file($this->tmpFile['tmp_name'])) {
            return false;
        }

        return true;
    }
399580
def has_file_extension(filepath, ext_required):
    '''
    '''
    ext = os.path.splitext(filepath)[-1]
    if ext != ext_required:
        msg_tmpl = "The extension for {}, which is {}, does not equal {}"
        msg_format = msg_tmpl.format(filepath, ext, ext_required)
        raise ValueError(msg_format)
    return True
364317
public function validateFile()
    {
        $totalChunks = $this->request->getTotalChunks();
        $totalChunksSize = 0;

        for ($i = $totalChunks; $i >= 1; $i--) {
            $file = $this->getChunkPath($i);
            if (!file_exists($file)) {
                return false;
            }
            $totalChunksSize += filesize($file);
        }

        return $this->request->getTotalSize() == $totalChunksSize;
    }
162782
public function isValid()
    {
        // these schemes are allowed
        $allowedSchemes = $this->getAllowedSchemes();

        // get the field value
        $url = $this->field->getValue();


        // not required and empty? Then its valid
        if ($this->isNotRequiredAndEmpty($url)) {
            return true;
        }

        if ($this->getMaxLength() && strlen($url) > $this->getMaxLength()) {
            // Over maximum length.
            return false;
        }

        // do simple validation
        if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_SCHEME_REQUIRED)) {
            return false;
        }

        // check if we have a tld
        if (!$this->isSkipTldCheck() && !preg_match('#\.[a-z]{2,}$#', parse_url($url, PHP_URL_HOST))) {
            return false;
        }

        // further validation is required.
        if (in_array(parse_url($url, PHP_URL_SCHEME), $allowedSchemes)) {
            return true;
        }

        return false;
    }
804927
public function isValidPHPExtensions()
    {
        $extensions = array('xml', 'soap', 'curl');
        foreach ($extensions as $extension) {
            if (!extension_loaded($extension)) {
                return Splash::log()->err(
                    'PHP :'.$extension.' PHP Extension is required to use Splash PHP Module.'
                );
            }
        }

        return Splash::log()->msg(
            'PHP : Required PHP Extension are installed ('.implode(', ', $extensions).')'
        );
    }
482650
public function isValid() {
		
		$params = $this -> getParameters();
		$file 	= $this -> getFile();
		$info 	= (object) pathinfo($file['name']);
		$params = array_map(function($value) {

			if(false === is_string($value)) {
				return trigger_error(sprintf('Extension passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR);
			}

			return ltrim(strtolower($value), '.');
		}, $params);

		if(true === isset($info -> extension) && false === in_array($info -> extension, $params)) {
			return true;
		}

		return false;
	}
645693
private function verifyExtensionFile()
    {
        $supported_image = array(
            'gif',
            'jpg',
            'jpeg',
            'png'
        );

        $fileName = $_SERVER['HTTP_X_FILE_NAME'];

        $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (in_array($ext, $supported_image)) {
            return true;
        }
        return false;
    }
722258
public function isValid()
	{
		// loop through all files
		foreach ($this->container as $file)
		{
			// return false at the first non-valid file
			if ( ! $file->isValid())
			{
				return false;
			}
		}

		// only return true if there are uploaded files, and they are all valid
		return empty($this->container) ? false : true;
	}
1148475
public static function hasExtension($extension) {
		static::ensureDataLoaded();

		$extension = strtolower($extension);
		foreach (static::$mime_types as $extensions) {
			if (is_array($extensions)) {
				if (in_array($extension, $extensions, true)) {
					return true;
				}
			} else if ($extension === $extensions) {
				return true;
			}
		}

		return false;
	}
526404
private function _get_file_extension()
    {

        if (empty($this->u_mime_type)) return false;

        $tmp                  = explode('/', $this->u_mime_type);
        $this->file_extension = array_pop($tmp);

        unset($tmp);

        return true;
    }
146198
public function isPlainText()
    {
        $sc_pos = strpos($this->mime_type, ';');
        if ($sc_pos !== false)
            $mime_type = substr($this->mime_type, 0, $sc_pos);
        else
            $mime_type = $this->mime_type;
        
        // Some application/* types are plain text
        switch ($mime_type)
        {
            case "application/javascript":
            case "application/json":
            case "application/xml":
                return true;
        }

        // Assume all text/* files to be plain text
        return substr($mime_type, 0, 5) === "text/";
    }
395649
private function _extract_file_extension()
    {

        if (empty($this->filename)) return false;

        if (!empty($this->mime_type)) {
            $array                = explode('/', $this->mime_type);
            $this->file_extension = array_pop($array);
        } else {
            if (strpos($this->filename, '.') !== false) {
                $array                = explode('/', $this->mime_type);
                $this->file_extension = array_pop($array);
            } else {
                $this->file_extension = 'unknown';
            }
        }

        return true;
    }
719901
public function isValid()
    {
        // get files for upload
        $this->files = $this->request->getUploadedFiles();

        if (sizeof($this->files) > 0) {

            // do any actions if files exists

            foreach ($this->files as $n => $file) {

                // apply all the validation rules for each file

                foreach ($this->rules as $key => $rule) {

                    if (method_exists($this->validator, 'check' . ucfirst($key)) === true) {
                        $this->validator->{'check' . ucfirst($key)}($file, $rule);
                    }
                }
            }
        }

        $errors = $this->getErrors();

        return (empty($errors) === true) ? true : false;
    }
383438
public function validateAllowEmpty()
    {
        $val = $this->val();

        if (($val === null || $val === '') && !$this->allowEmpty()) {
            return false;
        } else {
            return true;
        }
    }
1120751
protected function validateFileSize()
    {
        if (!is_numeric($this->max_file_size) && !is_int($this->max_file_size)) {
            // it is not set max file size limitation.
            return true;
        }

        if (is_array($this->files[$this->input_file_name]) && array_key_exists('size', $this->files[$this->input_file_name]) && $this->files[$this->input_file_name]['size'] > $this->max_file_size) {
            $this->setErrorMessage(
                sprintf(static::__('The uploaded file exceeds the max file size directive. (%s &gt; %s).'), $this->files[$this->input_file_name]['size'], $this->max_file_size),
                'RDU_1',
                $this->files[$this->input_file_name]['size'] . ' &gt; ' . $this->max_file_size,
                $this->files[$this->input_file_name]['name'],
                $this->files[$this->input_file_name]['size'],
                $this->files[$this->input_file_name]['type']
            );
            return false;
        } else {
            if (is_array($this->files[$this->input_file_name]) && array_key_exists('tmp_name', $this->files[$this->input_file_name]) && function_exists('filesize')) {
                if (filesize($this->files[$this->input_file_name]['tmp_name']) > $this->max_file_size) {
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded file exceeds the max file size directive. (%s &gt; %s).'), $this->files[$this->input_file_name]['size'], $this->max_file_size),
                        'RDU_1',
                        $this->files[$this->input_file_name]['size'] . ' &gt; ' . $this->max_file_size,
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                }
            }
        }

        return true;
    }