-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.php
45 lines (35 loc) · 1.03 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php declare(strict_types=1);
use Palmtree\Form\Constraint\File as FileConstraint;
use Palmtree\Form\FormBuilder;
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../.bootstrap.php';
$builder = new FormBuilder([
'key' => 'fileupload_example',
'action' => 'index.php',
'ajax' => false,
'html_validation' => false,
]);
$builder->add('file', 'file', [
'constraints' => [
new FileConstraint\Size([
'max' => 1024 * 100,
]),
new FileConstraint\Extension([
'extensions' => ['jpg', 'gif', 'png'],
]),
new FileConstraint\MimeType([
'mime_types' => ['image/jpeg', 'image/gif', 'image/png'],
]),
],
]);
$builder->add('send_message', 'submit');
$form = $builder->getForm();
$form->handleRequest();
if ($form->isSubmitted() && $form->isValid()) {
redirect('?success=1');
}
$view = template('view.phtml', [
'form' => $form,
'success' => (!empty($_GET['success'])),
]);
echo $view;