I'd like to upload an image using Angular and Laravel. It's seems pretty easy but it's not. I copy my code it speaks for itself:
html:
<input type="file" name="image" id="image" custom-on-change="uploadFile">
Angular:
var f = document.getElementById('image').files[0];
var fd = new FormData();
fd.append("image",f);
Question.post({
'name': this.name,
'parent': this.parent,
'image' : fd
}).then(function () {
$prevstate.go()
}, function (response) {
let alert = { type: 'error', 'title': 'Error!', msg: response.data.message }
$state.go($state.current, { alerts: alert })
})
And in the controller I have tried every way I found on the net but I got null everytime instead of my image:
Input::hasFile('image')
$request->hasFile('image')
$image = Input::file('image');
$image = ($request->file('image')
No matter what method I use always returns with false or null. I hope you will find what I'm doing wrong. Thanks