File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ When the HTML form is submitted, the server-side PHP code can validate and uploa
39
39
40
40
``` php
41
41
$storage = new \GravityPdf\Upload\Storage\FileSystem('/path/to/directory');
42
+ // To override existing files when uploading, pass `true` as the second paramter
43
+ // $storage = new \GravityPdf\Upload\Storage\FileSystem('/path/to/directory', true);
42
44
$file = new \GravityPdf\Upload\File('foo', $storage);
43
45
44
46
// Validate file upload
@@ -69,7 +71,9 @@ $data = [
69
71
70
72
// If you have an upload field that accepts multiple files you can access each file's info individually
71
73
$firstFileName = $file[0]->getNameWithExtension();
72
- $secondFileName = $file[1]->getNameWithExtension();
74
+ if(isset($file[1])) {
75
+ $secondFileName = $file[1]->getNameWithExtension();
76
+ }
73
77
74
78
// or loop over all files for this key
75
79
foreach($file as $upload) {
82
86
// Success!
83
87
$file->upload();
84
88
} catch (\Exception $e) {
85
- // Fail!
89
+ // Validation errors
86
90
$errors = $file->getErrors();
91
+ if(count($errors) === 0) {
92
+ // Failed for another reason, like the file already exists
93
+ $error = $e->getMessage();
94
+ }
87
95
}
88
96
```
89
97
You can’t perform that action at this time.
0 commit comments