Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c955890

Browse files
Create File-uplading.md
1 parent a16d349 commit c955890

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

File-uplading.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## File Uploading
2+
3+
File uploading is very simple and easy in unic framework.
4+
5+
Let's handle file uploading:
6+
```php
7+
$app->post('/file', function($req, $res) {
8+
// Save uploaded file
9+
if ($req->files->has('image')) {
10+
$req->files->get('image')->save(base_path('public'));
11+
}
12+
// Get all file details
13+
$res->json($req->files->getAll());
14+
});
15+
```
16+
17+
We can access uploaded file details using `$req->files` object.
18+
19+
Change uploaded file name:
20+
21+
```php
22+
$req->files->get('image')->save(base_path('public'), 'cat.png');
23+
```

0 commit comments

Comments
 (0)