Concerns
4 years ago
Contracts
4 years ago
Exceptions
4 years ago
Facades
4 years ago
FormFieldMediator
5 years ago
Checkbox.php
4 years ago
Date.php
4 years ago
Element.php
4 years ago
Email.php
4 years ago
Factory.php
4 years ago
Field.php
4 years ago
File.php
4 years ago
Form.php
4 years ago
Group.php
4 years ago
Hidden.php
4 years ago
Option.php
4 years ago
Phone.php
4 years ago
Radio.php
4 years ago
Select.php
4 years ago
Text.php
4 years ago
Textarea.php
4 years ago
Types.php
4 years ago
Url.php
4 years ago
File.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\FieldsAPI; |
| 4 | |
| 5 | /** |
| 6 | * A file upload field. |
| 7 | * |
| 8 | * @since 2.12.0 |
| 9 | */ |
| 10 | class File extends Field { |
| 11 | |
| 12 | use Concerns\AllowMultiple; |
| 13 | use Concerns\HasEmailTag; |
| 14 | use Concerns\HasHelpText; |
| 15 | use Concerns\HasLabel; |
| 16 | use Concerns\ShowInReceipt; |
| 17 | use Concerns\StoreAsMeta; |
| 18 | |
| 19 | const TYPE = 'file'; |
| 20 | |
| 21 | /** @var int */ |
| 22 | protected $maxSize = 1024; |
| 23 | |
| 24 | /** @var string[] */ |
| 25 | protected $allowedTypes = [ '*' ]; |
| 26 | |
| 27 | /** |
| 28 | * Set the maximum file size. |
| 29 | * |
| 30 | * @param int $maxSize |
| 31 | * @return $this |
| 32 | */ |
| 33 | public function maxSize( $maxSize ) { |
| 34 | $this->maxSize = $maxSize; |
| 35 | return $this; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Access the maximum file size. |
| 40 | * |
| 41 | * @return int |
| 42 | */ |
| 43 | public function getMaxSize() { |
| 44 | return $this->maxSize; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Set the allowed file types. |
| 49 | * |
| 50 | * @param string[] $allowedTypes |
| 51 | * @return $this |
| 52 | */ |
| 53 | public function allowedTypes( $allowedTypes = [ '*' ] ) { |
| 54 | $this->allowedTypes = $allowedTypes; |
| 55 | return $this; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Access the allowed file types. |
| 60 | * |
| 61 | * @return string[] |
| 62 | */ |
| 63 | public function getAllowedTypes() { |
| 64 | return $this->allowedTypes; |
| 65 | } |
| 66 | } |
| 67 |