- Laravel 5.7
- upload_max_filesize = 200m
- post_max_size = 250m
$request->hasFile('image') is returning null, even though I can clearly see the request holding an image key returning with a valid base64 (validated it to be an image)
controller
if ($request->hasFile('image')) { return 'yes'; }else{ echo 'no'; return $request->all(); } front
<form @submit.prevent="saveOoi" enctype="multipart/form-data"> <div><img :src="image" class="embed-responsive"></div> <input type="file" v-on:change="onFileChange" class="form-control mb-3" name="image"> </form> scripts
data() { return { image: '', errors: new Errors(), } }, methods: { onFileChange(e) { let files = e.target.files || e.dataTransfer.files; if (!files.length) return; this.createImage(files[0]); this.$data.image = files[0]; }, createImage(file) { let reader = new FileReader(); let vm = this; reader.onload = (e) => { vm.image = e.target.result; }; reader.readAsDataURL(file); }, saveOoi() { axios.post('ooi', this.$data) .then(response => console.log('sent', response)) .catch(error => this.errors.record(error.response.data)); } } i have the vue extension for chrome and I can see that the file is set in data.image when I pick the file.
What am I missing here?
$request->all()when sending images, that would be helpful.