@props([ 'src' => '', 'accept' => '*', ])
except(['wire:model']) !!} x-data="{ fileUrl: '{{ $src }}', file: null, fileInput: null, initFileInput() { this.fileInput = this.$el.querySelector('input[type=file]') this.fileInput.addEventListener('change', () => { this.file = this.fileInput.files[0] this.fileUrl = URL.createObjectURL(this.file) }) }, destroyFileInput() { this.fileInput.removeEventListener('change') }, remove() { if (!confirm('Are you sure?')) return this.fileUrl = '' this.file = null this.fileInput.value = '' this.$dispatch('removed') } }" x-init="initFileInput" x-on:destroy.window="destroyFileInput">
{{-- Show the filename --}} {{-- File selector --}} only([ 'wire:model']) !!}> {{-- Upload and remove buttons --}}