Skip to content

Commit

Permalink
change readme
Browse files Browse the repository at this point in the history
  • Loading branch information
slince committed Sep 5, 2018
1 parent 44985a5 commit 8a93d85
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,8 @@ $handler = $builder
->getHandler();

$files = $handler->handle();

foreach ($files as $file) {
$uploadedFile = $file->getUploadedFile();
if ($file->isUploaded()) {
echo $uploadedFile->getClientOriginalName() . ' upload ok, path:' . $file->getDetails()->getPathname();
} else {
echo $uploadedFile->getClientOriginalName() . ' upload error: ' . $file->getException()->getMessage();
}
echo PHP_EOL;
}
```

File details (`$file->getDetails()`) is provided by storage layer. if you are using `Local`, it is an instance of `SplFileInfo`.

If you want access attributes of the file saved in the client, you can use like this.

```php
$files['foo']->getUploadedFile()->getClientOriginalName(); // original name
$files['bar']['baz'][0]->getUploadedFile()->getClientOriginalExtension(); // original extension
$files['bar']['baz'][1]->getUploadedFile()->getClientMimeType(); // original mime type
print_r($files);
```

### Advanced usage

```php
Expand All @@ -82,6 +62,25 @@ $handler = $builder
->getHandler();

$files = $handler->handle();

foreach ($files as $file) {
$uploadedFile = $file->getUploadedFile();
if ($file->isUploaded()) {
echo $uploadedFile->getClientOriginalName() . ' upload ok, path:' . $file->getDetails()->getPathname();
} else {
echo $uploadedFile->getClientOriginalName() . ' upload error: ' . $file->getException()->getMessage();
}
echo PHP_EOL;
}
```
File details (`$file->getDetails()`) is provided by storage layer. if you are using `Local`, it is an instance of `SplFileInfo`.

If you want access attributes of the file saved in the client, you can use like this.

```php
$files['foo']->getUploadedFile()->getClientOriginalName(); // original name
$files['bar']['baz'][0]->getUploadedFile()->getClientOriginalExtension(); // original extension
$files['bar']['baz'][1]->getUploadedFile()->getClientMimeType(); // original mime type
```

### Integration with [flysystem](https://github.com/thephpleague/flysystem)
Expand Down

0 comments on commit 8a93d85

Please sign in to comment.