Does this console log show the expected thumbnail ?
console.log(data.thumbnail)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So i try to create a update thumbnail feature with Inertia React, and this is the code:
ArticleItem: const { data, setData, patch, errors, reset, processing } = useForm({ thumbnail: article.thumbnail })
function onSubmitThumbnailChangeHandler(e) {
e.preventDefault()
console.log(data.thumbnail)
patch(`/articles/${article.id}/editThumbnail`, { onSuccess: () => reset() })
}
{errors.thumbnail &&
<p className="mt-2 text-sm text-red-700">{errors.thumbnail}</p>
}
<div className="justify-end flex gap-3 mt-6">
<button type="submit" disabled={processing} className={`mt-4 w-full py-2 px-4 bg-darkerBlue rounded-lg text-white ${processing && 'opacity-25'}`}>Save</button>
</div>
</form>
ArticleController: public function updateThumbnail(Request $request, Article $article) { $validated = $request->validate([ 'thumbnail' => 'required|mimes:png,jpg,jpeh' ]);
$article->update($validated);
return redirect('/admin');
}
When i try to upload the file then submit it there's an error: thumbnail field is required
What happen??? please help thank you
nevermind i've solved it
const { data, setData, post, errors, processing } = useForm({ thumbnail: article.thumbnail, _method: 'patch' })
function onSubmitThumbnailChangeHandler() {
console.log(data.thumbnail)
post(`/articles/${article.id}/editThumbnail`)
}
Please or to participate in this conversation.