Retrieve files from Vue in Laravel
I uploaded files from my frontend using Vue to Laravel backend.
Uploaded using this snippet below:
addPost() {
axios.post('api/submitPropertyPhoto?token=' + this.token, this.postFormData)
.then(r => {
console.log(r)
})
.catch(e => {
console.log(e)
}
},
uploadFieldChange(e) {
for(let key in e.target.files) {
this.postFormData.append('images[]', e.target.files[key])
}
}
When I want to request the file using normal Laravel request file helper method it returns nothing but when I use dd($request->files)
it returns the details below.
FileBag {#68
#parameters: array:1 [
"images" => array:1 [
0 => array:1 [
"name" => UploadedFile {#45
-test: false
-originalName: "error.JPG"
-mimeType: "image/jpeg"
-size: 21806
-error: 0
path: "C:xampptmp"
filename: "php639F.tmp"
basename: "php639F.tmp"
pathname: "C:xampptmpphp639F.tmp"
extension: "tmp"
realPath: "C:xampptmpphp639F.tmp"
aTime: 2018-05-17 04:26:29
mTime: 2018-05-17 04:26:29
cTime: 2018-05-17 04:26:29
inode: 0
size: 21806
perms: 0100666
owner: 0
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
linkTarget: "C:xampptmpphp639F.tmp"
}
]
]
]
}
What I want to achieve basically is to save the file in the disc and the file name in the database.
from Laravel Questions and Answers https://laravelquestions.com/laravel/retrieve-files-from-vue-in-laravel/
via Lzo Media
No comments:
Post a Comment