0👍
VueJS
const config = {
headers: { 'content-type': 'multipart/form-data' }
}
let formData = new FormData();
formData.append('file', this.file);
formData.append('text', this.text);
axios
.post('Your URL', formData, config)
.then(( data ) => {
console.log(data);
})
.catch((e) => {
console.log(e);
})
Laravel/PHP
private function something(Request $request) {
$fileName = time().$request->file->getClientOriginalName();
$textName = $request->input('text');
//You can check the data by DD example
dd($textName); //dd($fileName)
//You can also save or move the file by
$request->file->move(public_path('storage/'), $fileName);
}
Source:stackexchange.com