I create a component to create a post, my form has an input file with wire:model="post.post_image" , when I choose an image, I create a function to print the image data but it still gives me null.
use WithFileUploads;
public $post;
protected $rules = [
'post.post_image' => 'sometimes|image|max:5000',
];
public function mount ()
{
$this->post = new Post;
}
public function uploadPostImage(Request $request)
{
dd($request->file('post.post_image'));
}
public function render ()
{
return view('livewire.post.create');
}
html code :
<div class="sm:col-span-6"> <input type="file" accept="image/*" wire:model="post.post_image" name="post.post_image" wire:change="uploadPostImage"> </div>
when i upload image it give me null and in console give me this error