Skip to content

Commit 4815748

Browse files
committed
Add file upload documentation
1 parent 60d672a commit 4815748

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,34 @@ For spatial support there is an extra set of filters that can be applied on geom
577577

578578
These filters are based on OGC standards and so is the WKT specification in which the geometry columns are represented.
579579

580+
### File uploads
581+
582+
If you add the 'fileUpload' middleware you can also upload a file using a web form (multipart/form-data):
583+
584+
```
585+
<form method="post" action="http://localhost/api.php/records/categories" enctype="multipart/form-data">
586+
Select image to upload:
587+
<input type="file" name="icon">
588+
<input type="submit">
589+
</form>
590+
```
591+
592+
Then this is handled as if you would have sent:
593+
594+
```
595+
POST http://localhost/api.php/categories
596+
{"icon_name":"not.gif","icon_type":"image\/gif","icon":"ZGF0YQ==","icon_error":0,"icon_size":4}
597+
```
598+
599+
As you can see the "xxx_name", "xxx_type", "xxx_error" and "xxx_size" meta fields are added (where "xxx" is the name of the file field).
600+
601+
NB: You cannot edit a file using this method, because browsers do not support the "PUT" method in these forms.
602+
580603
### Authentication
581604

582605
Authentication is done by means of sending a "Authorization" header. It identifies the user and stores this in the `$_SESSION` super global.
583606
This variable can be used in the authorization handlers to decide wether or not sombeody should have read or write access to certain tables, columns or records.
584-
Currently there are two types of authentication supported: "Basic" and "JWT".
607+
Currently there are two types of authentication supported: "Basic" and "JWT". This functionality is enabled by adding the 'basicAuth' and/or 'jwtAuth' middleware.
585608

586609
#### Basic authentication
587610

0 commit comments

Comments
 (0)