Firstly, adding the proper headers for uploading a file.
const submitFile = () => {
let inputFile = document.getElementById('browse-file').files[0]
let url = `https://google.com/test`
var data = new FormData()
data.append('file', inputFile)
axios.post(url, data, {headers: {'Content-Type': 'multipart/form-data'}})
.then(res => {
console.log(res)
}).catch(err => console.log(err))
}
Secondly, it's better to validate that the input is a file in the back-end
$request->validate([
'file' => 'required|file'
]);
$path = file_get_contents($request->file->path());