/** * Returns the specified accepted file types, or the default * based on the mode. Image mode will return: * - jpg,jpeg,bmp,png,gif,svg * @return string */ public function getAcceptedFileTypes($includeDot = false) { $types = $this->fileTypes; if ($types === false) { $isImage = starts_with($this->getDisplayMode(), 'image'); $types = implode(',', File::getDefaultFileTypes($isImage)); } if (!$types || $types == '*') { return null; } if (!is_array($types)) { $types = explode(',', $types); } $types = array_map(function ($value) use($includeDot) { $value = trim($value); if (substr($value, 0, 1) == '.') { $value = substr($value, 1); } if ($includeDot) { $value = '.' . $value; } return $value; }, $types); return implode(',', $types); }
/** * Returns the specified accepted file types, or the default * based on the mode. Image mode will return: * - jpg,jpeg,bmp,png,gif,svg * @return string */ protected function processFileTypes($includeDot = false) { $types = $this->property('fileTypes', '*'); if (!$types || $types == '*') { $types = implode(',', File::getDefaultFileTypes()); } if (!is_array($types)) { $types = explode(',', $types); } $types = array_map(function ($value) use($includeDot) { $value = trim($value); if (substr($value, 0, 1) == '.') { $value = substr($value, 1); } if ($includeDot) { $value = '.' . $value; } return $value; }, $types); return implode(',', $types); }