Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How do I upload files to pocketbase?

$
0
0

I am using pocketbase and svelte.js.How can I upload pictures to pocketbase via an html input.

<script lang="ts">    import { currentUser, pb } from './pocketbase';    const axios = require('axios').default;    const fileInput = document.getElementById('fileInput');    async function uploadFile() {        axios({            method: 'post',            url: 'http://127.0.0.1:8090/api/collections/images/records',            data: {                image: fileInput.file,            }        });    }</script><form enctype="multipart/form-data" method="post" on:submit={uploadFile}><input type="file" name="fileInput" id="fileInput"><button type="submit">Upload</button></form>

Viewing all articles
Browse latest Browse all 1541

Trending Articles