/** * Construct a new UploadField instance * * @param string $name The internal field name, passed to forms. * @param string $title The field label. * @param SS_List $items If no items are defined, the field will try to auto-detect an existing relation on * @link $record}, with the same name as the field name. */ public function __construct($name, $title = null, SS_List $items = null) { // TODO thats the first thing that came to my head, feel free to change it $this->addExtraClass('ss-upload'); // class, used by js $this->addExtraClass('ss-uploadfield'); // class, used by css for uploadfield only $this->ufConfig = self::config()->defaultConfig; parent::__construct($name, $title); if ($items) { $this->setItems($items); } // filter out '' since this would be a regex problem on JS end $this->getValidator()->setAllowedExtensions(array_filter(File::config()->allowed_extensions)); // get the lower max size $maxUpload = File::ini2bytes(ini_get('upload_max_filesize')); $maxPost = File::ini2bytes(ini_get('post_max_size')); $this->getValidator()->setAllowedMaxFileSize(min($maxUpload, $maxPost)); }
/** * Construct a new UploadField instance * * @param string $name The internal field name, passed to forms. * @param string $title The field label. */ public function __construct($name, $title = null) { $this->addExtraClass('ss-upload'); // class, used by js $this->addExtraClass('ss-uploadfield'); // class, used by css for uploadfield only $this->ufConfig = array_merge($this->ufConfig, self::config()->defaultConfig); parent::__construct($name, $title); // AssetField always uses rename replacement method $this->getUpload()->setReplaceFile(false); // filter out '' since this would be a regex problem on JS end $this->getValidator()->setAllowedExtensions(array_filter(File::config()->allowed_extensions)); // get the lower max size $maxUpload = File::ini2bytes(ini_get('upload_max_filesize')); $maxPost = File::ini2bytes(ini_get('post_max_size')); $this->getValidator()->setAllowedMaxFileSize(min($maxUpload, $maxPost)); }