Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

motinska94's avatar

Uploading/previewing HEIC images with Livewire

I'm working on an image upload page that shows a preview of the uploaded image with Livewire. I am using accept="image/*" on my HTML file element and it's showing HEIC images on my computer.

When I click on one of them, upload button appears (check the blade code below), but doesn't show the image preview. And when I click the upload button, I'm getting this error : "The image field must be an image"

	<input type="file" id="image" accept="image/*" class="hidden"/>

	@if($image)
		<label for="image" class="button">Click to select image</label>
	@else
		<img src="{{ $image->temporaryUrl() }}"/>
		<label for="image" class="button">Select another image</label>
		<button wire:click="uploadImage">Upload Image</button>
	@endif

I have published and edited my livewire config file as following, and manually included heic and heif formats in the preview_mimes array.

'temporary_file_upload' => [
        'disk' => null,
        'rules' => 'required|file|max:5120',
        'directory' => null,
        'middleware' => null,
        'preview_mimes' => [   // Supported file types for temporary pre-signed file URLs...
            'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
            'mov', 'avi', 'wmv', 'mp3', 'm4a',
            'jpg', 'jpeg', 'mpga', 'webp', 'wma', 'heic', 'heif'
        ],
        'max_upload_time' => 5,
        'cleanup' => true,
    ],
0 likes
3 replies
Snapey's avatar

but heic is not a supported web format. So either convert it on upload (and dont try preview until converted) or indicate on the file input that you only want png, jpg and webp

1 like
motinska94's avatar

@Snapey Thanks a lot! I'm accepting image uploads from users on this app and a sizable portion of them will be using iphone so I can't really require a certain format, but I'll try converting them first.

Though that doesn't really solve the second issue : And when I click the upload button, I'm getting this error : "The image field must be an image"

Maybe I shouldn't use livewire for this part.. I can remove the image validation but I feel like that'll cause even more problems.

Snapey's avatar
Snapey
Best Answer
Level 122

@motinska94 first of all, if your image upload does not accept heic, the phone will convert it automatically before sending.

the second part, image field must be an image and is just a validation error. I dont think you will get different results in laravel rather than livewire since its the same rules

1 like

Please or to participate in this conversation.