Called if $this->type === 'file'
507722
protected function render_file(): string
    {
        return '<input type="file" '.$this->metaString().
            ' id="'.$this->escape->attr($this->id).
            '" name="'.$this->escape->attr($this->name).'" />';
    }
813627
private function checkFileTypeIsAllowed()
	{
		if(count($this->allowedMimeTypes) > 0)
		{
			if(! in_array($this->file->getMimeType(), $this->allowedMimeTypes))
			{
				throw new InvalidFileTypeException("Invalid File Type: " . $this->file->getMimeType() . " has not been allowed");
			}
		}
	}
173530
def content_type
      type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
      case type
      when %r"jp(e|g|eg)"            then "image/jpeg"
      when %r"tiff?"                 then "image/tiff"
      when %r"png", "gif", "bmp"     then "image/#{type}"
      when "txt"                     then "text/plain"
      when %r"html?"                 then "text/html"
      when "js"                      then "application/js"
      when "csv", "xml", "css"       then "text/#{type}"
      else
        # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
        content_type = (Paperclip.run("file", "-b --mime-type :file", :file => self.path).split(':').last.strip rescue "application/x-#{type}")
        content_type = "application/x-#{type}" if content_type.match(/\(.*?\)/)
        content_type
      end
    end
1294059
public function isFile()
    {
        if ($this->blobExists()) {
            $metadata = $this->storage->getMetaData($this->blob->path);

            return $metadata['type'] === 'file';
        }

        return false;
    }
901103
public function isCorrectType($type, $path)
	{
		if ( ! $type)
		{
			return true;
		}

		if ( ! isset($this->typeCache[$path]))
		{
			$this->typeCache[$path] = is_file($path) ? 'file' : 'dir';
		}

		return $this->typeCache[$path] === $type;
	}
928953
public function file() {
        $this->check_role = 'file';
        if (!$this->value) {
            $result = false;
        } else if ($this->value instanceof File) {
            $result = is_file($this->value->path_tmp);
        } else {
            $result = is_file($this->value);
        }
        $this->checkResult($result);
        return $this;
    }
31834
function (type, data) {
  if (type === 'size') {
    return `File size should be less than ${bytes(data.size)}`
  }

  if (type === 'type') {
    const verb = data.types.length === 1 ? 'is' : 'are'
    return `Invalid file type ${data.subtype} or ${data.type}. Only ${data.types.join(', ')} ${verb} allowed`
  }

  if (type === 'extname') {
    const verb = data.extnames.length === 1 ? 'is' : 'are'
    return `Invalid file extension ${data.extname}. Only ${data.extnames.join(', ')} ${verb} allowed`
  }
}
357846
private boolean isFileType(WatchEvent event, String fileType) {
        return event.context().toString().contains(fileType);
    }
912957
protected function checkFile($path, $type, $file)
    {
        $filePath = implode('/', [$path, $type, $file]);

        if (is_file($filePath)) {
            return $filePath;
        } else {
            return false;
        }
    }
372142
def is_filelike(ob):
    
    if hasattr(ob, 'read') and callable(ob.read):
        return True

    if hasattr(ob, 'write') and callable(ob.write):
        return True

    return False
1367132
private function isAllowedFileType($file) {
	$path_parts = pathinfo($file);
	// if there is no extension AND no extension file are not allowed
	if(!isset($path_parts['extension']) && $this->config['security']['allowNoExtension'] == false) {
		return false;
	} else {
		return true;
	}
	$exts = array_map('strtolower', $this->config['security']['uploadRestrictions']);
	if($this->config['security']['uploadPolicy'] == 'DISALLOW_ALL') {
		if(!in_array(strtolower($path_parts['extension']), $exts))
			return false;
	}
	if($this->config['security']['uploadPolicy'] == 'ALLOW_ALL') {
		if(in_array(strtolower($path_parts['extension']), $exts))
			return false;
	}
	return true;
}
764761
function(file) {
      var type = file.type.toLowerCase(),
        sources = file.sources;

      $.each(sources, function(tmpSource) {
        if (_support[type][tmpSource]) {
          file = file.sources[tmpSource];
          file.type = type.toUpperCase();
          return false;
        }
      });
      if (file.source) {
        return file;
      } else {
        return false;
      }
    }
1114309
public static function getFileMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        if ($finfo) {
            $mime_type = finfo_file($finfo, $file);
            finfo_close($finfo);
            return $mime_type;
        }
        return false;
    }
501649
function store( $fileName, $filePath, $type )
    {
        if ( !$this->IsProcessed )
            $this->process();
        $imageObject = $this->imageObject();
        switch( $type )
        {
            case 'png':
            {
                if ( !file_exists( $filePath ) )
                {
                    eZDir::mkdir( $filePath, false, true );
                }
                $fileFullPath = eZDir::path( array( $filePath, $fileName ) );
                ImagePNG( $imageObject, $fileFullPath );
                $this->StoredPath = $filePath;
                $this->StoredFile = $fileName;
                $this->StoredType = $type;
                return true;
            } break;

            case 'jpg':
            {
                if ( !file_exists( $filePath ) )
                {
                    eZDir::mkdir( $filePath, false, true );
                }
                ImageJPEG( $imageObject, eZDir::path( array( $filePath, $fileName ) ) );
                $this->StoredPath = $filePath;
                $this->StoredFile = $fileName;
                $this->StoredType = $type;
                return true;
            } break;

            default:
            {
                eZDebug::writeError( 'Image format not supported: ' . $type, __METHOD__ );
            }
        }
        return false;
    }
1308297
public static function checkType($item)
    {
        if (is_string($item)) {
            // Item is a string; check to see if it's a URL or filepath
            if (filter_var($item, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
                // Item is a URL
                return Type::URL;
            } elseif (is_file(config('filer.path.absolute') . "/{$item}")) {
                // Item is a filepath
                return Type::FILEPATH;
            }
        } elseif (is_a($item, 'SplFileInfo')) {
            // Item is a file object
            return Type::FILE;
        }

        // Throw an exception if item doesn't match any known types
        throw new Exception('Unknown item type');
    }
1153499
public function is_filetype_group($type) {

        $info = $this->get_groups_info();

        if (isset($info[$type])) {
            return $info[$type];

        } else {
            return false;
        }
    }
948336
def prompt_filetype(args):
    """"""
    valid_types = ('print', 'text', 'csv', 'pdf', 'html')
    if not any(args[x] for x in valid_types):
        try:
            filetype = input('Print or save output as ({0}): '
                             .format(', '.join(valid_types))).lower()
            while filetype not in valid_types:
                filetype = input('Invalid entry. Choose from ({0}): '
                                 .format(', '.join(valid_types))).lower()
        except (KeyboardInterrupt, EOFError):
            return
        args[filetype] = True