Hej,
Mam pewien problem. Udało mi się zrobić skrypt który przesyła na serwer pliki. Problem pojawił się w momencie, gdzie chciałem użyć go także w metodzie patch. Przy post wszystko działa natomiast przy użyciu patch, pojawia mi się następujący błąd:
message: Call to a member function getClientOriginalExtension() on null
chooseImage () {
this.$refs.fileInput.click()
},
onSelectFile () {
const input = this.$refs.fileInput;
const files = input.files;
if (files && files[0]) {
const reader = new FileReader
reader.onload = e => {
this.singleNews.thumb = e.target.result
}
reader.readAsDataURL(files[0])
this.$emit('input', files[0])
}
this.image = files[0];
console.log(this.image);
},
update(){
const config = {
headers: { 'content-type': 'multipart/form-data' }
}
//
let formData = new FormData();
formData.append('image', this.image);
//
axios.patch(this.uri + this.singleNews.references, formData, config)
},
<form v-on:submit.prevent="update" enctype="multipart/form-data">
<div class="image-input mb-5" :style="{ 'background-image': `url(${singleNews.thumb})` }" @click="chooseImage">
<span v-if="!singleNews.thumb" class="placeholder">
Selectionner une image de couverture
</span>
<input class="file-input" ref="fileInput" type="file" @input="onSelectFile">
</div>
...
</form>
public function update(Request $request, $references){
$imageName = time().'.'.$request->image->getClientOriginalExtension();
$request->image->move(public_path('images'), $imageName);
}
Problem jest błachy ale nie mogę dość czemu nagle skrypt nie może pobrać informacji na temat obrazka