Problem in replacing avatar js / livewire

hello
1 Reply
NIMA
NIMAOP2w ago
<form >
<div class="flex items-center space-x-6">
<div class="shrink-0">
<img id='myImg' wire:loading.class="opacity-50" class="h-16 w-16 object-cover rounded-full" src="{{ Storage::url('avatar/' . $profile_avatar )}}" />
</div>
<label class="block cursor-pointer">
<span class="sr-only">Choose profile photo</span>
<input wire:model="photo" type='file' id='fileName' name='fileName' capture='user' accept='image/*' onchange="document.getElementById('myImg').src = window.URL.createObjectURL(this.files[0])" class="hidden" />
<span class="font-bold outline-none px-4 border border-black text-black cursor p-2 px-4 dark:hover:bg-zinc-600 hover:bg-zinc-200 cursor-pointer rounded-md dark:text-white dark:border-white">Chenge</span>
</label>
<button wire:click="image_upload" class="outline-none border-none h-10 px-4 bg-neutral-800 text-white text-black cursor p-2 px-4 dark:hover:bg-zinc-200 hover:bg-zinc-700 cursor-pointer rounded-md dark:text-black dark:bg-white">Save</button>
</div>
</form>
<form >
<div class="flex items-center space-x-6">
<div class="shrink-0">
<img id='myImg' wire:loading.class="opacity-50" class="h-16 w-16 object-cover rounded-full" src="{{ Storage::url('avatar/' . $profile_avatar )}}" />
</div>
<label class="block cursor-pointer">
<span class="sr-only">Choose profile photo</span>
<input wire:model="photo" type='file' id='fileName' name='fileName' capture='user' accept='image/*' onchange="document.getElementById('myImg').src = window.URL.createObjectURL(this.files[0])" class="hidden" />
<span class="font-bold outline-none px-4 border border-black text-black cursor p-2 px-4 dark:hover:bg-zinc-600 hover:bg-zinc-200 cursor-pointer rounded-md dark:text-white dark:border-white">Chenge</span>
</label>
<button wire:click="image_upload" class="outline-none border-none h-10 px-4 bg-neutral-800 text-white text-black cursor p-2 px-4 dark:hover:bg-zinc-200 hover:bg-zinc-700 cursor-pointer rounded-md dark:text-black dark:bg-white">Save</button>
</div>
</form>
im using this so i can show the user avatar and if he press chenge button he can see the avatar in frame then replace it but as soon i replace the avatar after 1 secend it will back to the old avatar im using Livewire / js / laravel anyone know the problem how can i fix this ? even if i press chenge the new photo will be save but it just wont show it until i press chenge Sloved

Did you find this page helpful?