Reputation: 4248
i am facing strange issue. When i upload the image(jpg,jpeg,png) file using livewire its working fine but when i try to upload any other file type its giving me error this error This driver does not support creating temporary URLs. Not sure is livewire doesnot support to upload doc, docx, pdf, csv xls, xlsx if yes its very strange?. Or i am doing something wrong in code. here is my below code:-
<form wire:submit.prevent="save">
<input type="file" wire:model="documnet">
@error('documnet') <span class="error">{{ $message }}</span> @enderror
<!-- Progress Bar -->
<div x-show="isUploading">
<progress max="100" x-bind:value="progress"></progress>
</div>
<div wire:loading wire:target="save">Uploading...</div>
<button type="submit">Save documnet</button>
</form>
In this user input any type of document (jpg, jpeg, png , doc, docx, pdf, csv xls, xlsx ). Here is my below component code
public function save(){
$extension = $this->document->getClientOriginalExtension();
// Filename to store
$fileNameToStore = uniqid().'_'.time().'.'.$extension;
// Upload Image
$path = $this->document->storeAs('public',$fileNameToStore);
}
Can anyone help me what i am doing wrong or livewire not supports to upload these extensions?
Upvotes: 1
Views: 2424
Reputation: 106
publish the config file with,
php artisan livewire:publish --config
Then add mime type of file you want to upload to preview_mimes under the temporary_upload_file in config file.
Upvotes: 5
Reputation: 11
Supported file types for temporary file urls are set in: config/livewire.php temporary_file_upload->preview_mimes array for support
Upvotes: 1