Validate an image upload in Laravel and Vue

The image rule checks the upload. Send it as POST with a file field, including when you are updating.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-image-rule-vue.md
The image rule checks the upload. Send it as POST with a file field, including when you are updating.
Do not point axios.put at the same URL with a FormData body and expect the file to arrive.
Do not run storage:link on Laravel Cloud.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel image validation Vue” attach a file and get “the cover field is required” or a 500. The usual cause is a PUT request. PHP does not parse files on PUT. The file upload guide shows the form. This page is the rule.

TL;DR

  • The image rule checks the upload.
  • Send it as POST with a file field, including when you are updating.
  • Do not point axios.put at the same URL with a FormData body and expect the file to arrive.
  • Do not run storage:link on Laravel Cloud.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

php
$validated = $request->validate([
    'cover' => ['required', 'image', 'max:2048'],
]);

$path = $validated['cover']->store('covers', 'public');

image allows the types Laravel treats as images. max:2048 is kilobytes, so this is 2 MB. A Vue accept="image/*" is a hint to the file picker. It is not the check.

vue
<Form action="/posts" method="post" v-slot="{ errors, processing }">
  <input type="file" name="cover" />
  <p v-if="errors.cover">{{ errors.cover }}</p>
  <button type="submit" :disabled="processing">Upload</button>
</Form>

To replace a cover on an existing post, keep method="post" and send _method as put. The Form component does that when the Wayfinder action is an update. Do not point axios.put at the same URL with a FormData body and expect the file to arrive.

What to avoid#

Gotcha

Do not run storage:link on Laravel Cloud. The deploy guide says the symlink does not survive there.

FAQ#

How do I validate an image upload in Laravel and Vue?

The image rule checks the upload. Send it as POST with a file field, including when you are updating.

What goes wrong with Laravel image validation Vue?

Many developers attach a file and get "the cover field is required" or a 500. Do not point axios.put at the same URL with a FormData body and expect the file to arrive.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.