# Receive file uploads

> Accept multipart/form-data with the @upload flag and read the uploaded files from $.files.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: en
Content-SHA256: cc8e1202c301ef7d57c6d2a4ded68c22fafe339ba7779514ef55c287d3e83d74
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Mark the route with `@upload` so it only accepts `multipart/form-data`, and set a size limit that fits the files you expect (here `<5mb`). The uploaded files are in `$.files`; the other fields of the form are in `$.body`. Each file has `name`, `filename`, `size` and `type`, and methods such as `read()`, `copy()` and `move()`.

```js controllers/upload.js
exports.install = function() {
	ROUTE('POST /upload/ @upload <5mb', upload);
};

function upload($) {

	var file = $.files[0];

	if (!file) {
		$.invalid('No file');
		return;
	}

	file.read(function(err, buffer) {
		$.json({
			filename: file.filename,
			size: file.size,
			type: file.type,
			text: buffer.toString('utf8'),
			title: $.body.title
		});
	});
}
```
