File(image) upload and storage

This commit is contained in:
Torsten 2020-02-06 08:15:12 +01:00
parent 0263c0f838
commit 81f32f2d09
7 changed files with 43 additions and 19 deletions

View file

@ -125,11 +125,17 @@
onFileSelected(event) {
console.log("File changed:");
console.log(event.target.files[0].name);
const fd = new FormData();
fd.append('image',event.target.files[0],event.target.files[0].name);
axios.post('http://localhost:8000/api/v1/auth/upload',fd,{
var selectedFile=event.target.files[0];
const formData = new FormData();
//formData.append('image',selectedFile,selectedFile.name);
formData.append('image',selectedFile);
const config=
axios.post('http://localhost:8000/api/v1/auth/upload',formData,{
headers: {
'Authorization': 'Bearer ' + this.$store.state.user_token
'Authorization': 'Bearer ' + this.$store.state.user_token,
'Content-Type': 'multipart/form-data'
}
})
.then(res=>{