# filetobase64

> File to base64

Latest version **0.0.4** (published 2017-05-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install filetobase64
pnpm add filetobase64
yarn add filetobase64
bun add filetobase64
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2017-05-22 |
| First published | 2014-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Miguel Mota |
| Maintainers | miguelmota |
| Keywords | file, base64 |

## Links

- npm: https://www.npmjs.com/package/filetobase64
- Repository: https://github.com/miguelmota/filetobase64
- Issues: https://github.com/miguelmota/filetobase64/issues
- npm.io page: https://npm.io/package/filetobase64

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.0.4 (latest) — 2017-05-22
- 0.0.3 — 2014-11-02
- 0.0.2 — 2014-10-31
- 0.0.1 — 2014-10-31

## README

# File to Base64

Takes in a File object and returns a base64 string with the help of the [`FileReader`](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) API.

# Demo

[https://lab.miguelmota.com/filetobase64](https://lab.miguelmota.com/filetobase64)

# Install

```bash
bower install filetobase64
```

```bash
npm install filetobase64
```

# Usage

```html
<input type="file" id="file" accept="image/*">

<img id="output">

<script src="filetobase64.js"></script>
```

```javascript
var fileInput = document.getElementById('file');
var output = document.getElementById('output');

fileInput.addEventListener('change', function(e) {
  var file = e.currentTarget.files[0];

  fileToBase64(file, function(base64) {
    console.log(base64); // iVBORw0KGgoAAAANSUhEUgAAADY...

    output.src = 'data:' + file.type + ';base64,' + base64;
  });

}, false);
```

# License

MIT

---
_Source: https://npm.io/package/filetobase64 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
