реакт компонент
import React, { useState } from 'react'
import axios from 'axios';
const Upload = () => {
const sendOnServer = () => {
const reader = new FileReader();
reader.onloadend = () =>
axios.post('http://localhost:3000/api/music/upload', {
buffer: reader.result,
author: 'kkk',
title: 'lkkk',
});
reader.readAsBinaryString(file[0]);
};
const [file, setFile] = useState(null);
return (
<div>
<input type="file" onChange={(e)=>setFile(e.target.files)}/>
<button onClick={sendOnServer}>Upload</button>
</div>
)
};
export default Upload;