<script> import axios from 'axios' export default { name: 'App', data () { return { serverLink: 'http://localhost:3000/upload/' } }, methods: { filesChange (filename, files) { if (!files.length) { return } console.log(filename, files) const formData = new FormData() for (let i = 0; i < files.length; i++) { formData.append(filename, files[i], files[i].name) } axios.post(this.serverLink, formData).then( rsp => { console.log(rsp) } ).catch(err => { console.log(err) }) } } } </script>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter