I see log Unable to guess the MIME type as no guessers are available (have you enabled the php_fileinfo extension?).
It gives an error when I select a photo in the Livewire component
My project is with Laravel and Livewire There was no problem in the local environment, I could easily select the photo and show it in the preview, and the photo would be uploaded. But when I got the project on the server When I select a photo in a form, it gives me an error: Image file upload was not successful. I tried all the ways from changing the disk upload file to executing the command php artisan storage: link But again, I did not get results
Code of one of the components
use AuthorizesRequests; use WithPagination; use WithFileUploads; protected $paginationTheme = 'bootstrap'; protected $queryString= ['search']; public $search; public $brand; public $tasvir;
protected $listeners = [
'update.brands.list' => '$refresh',
];
protected $rules = [
'brand.title' => 'required|min:3' ,
'tasvir' => 'required',
];
public function updated($value) // for realtime validation
{
$this->validateOnly($value);
}
public function createNewBrands()
{
if (! Gate::allows('create-brand')){
$this->dispatchBrowserEvent('alert',
['type' => 'info', 'message' => 'شما اجازه ایجاد دسته بندی را ندارید']);
return ;
}
$this->validate(); // اگر تصویر بود آدرس تصویر گرفته شود
if ($this->tasvir):
$imageaddress = $this->uploadMyPhotos();
else:
$imageaddress = null;
endif;
Brand::create([
'title' => $this->brand['title'],
'image' => $imageaddress,
]);
$this->emit('update.brands.list');
$this->brand = null;
$this->tasvir = null;
$this->dispatchBrowserEvent('alert',
['type' => 'success', 'message' => 'برند مورد نظر با موفقیت ایجاد شد']);
}
public function uploadMyPhotos() // upload photos
{
$year = now()->year;
$month = now()->month;
$day = now()->day;
$dir = "uploads/$year/$month/$day";
$name = rand(1000 , 99999) . '-' . $this->tasvir->getClientOriginalName();
$this->tasvir->storeAs($dir , $name);
return "$dir/$name";
}
public function deleteThisBrands(Brand $brand)
{
if (! Gate::allows('delete-brand')){
$this->dispatchBrowserEvent('alert',
['type' => 'info', 'message' => 'شما اجازه حذف برند را ندارید']);
return ;
}
$brand->delete();
$this->emit('update.brands.list');
$this->dispatchBrowserEvent('alert',
['type' => 'success', 'message' => 'برند مورد نظر با موفقیت حذف شد']);
}
public function render()
{
$this->authorize('show-brands');
$brands = Brand::where('title' , 'LIKE' , "%{$this->search}%")
->latest()
->paginate(6);
return view('livewire.admin.products.brands.all-brands' , compact('brands'))->layout('livewire.admin.layouts.master');
}
This is also the blade code
نام @error('brand.title') {{ $message }} @enderror تصویر شاخص <input wire:model.debounce="tasvir" id="image" type="file" class="form-control">
<span wire:target="tasvir" wire:loading>
<span class="spinner-border spinner-border-sm text-danger"></span>
</span>
@error('tasvir')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="col-6">
@if($tasvir)
<img class="img-fluid" width="100" height="100" src="{{ $tasvir->temporaryUrl() }}" alt="">
@endif
</div>
<div class="col-6">
<button class="btn btn-success">ایجاد brand</button>
</div>
</div>
</form>
When I select a photo, it gives an error: Image file upload was not successful. I also deleted the server public_html folder And I renamed my project public folder to public_html appServiceProvider code
public function register()
{
$this->app->bind('path.public' , function(){
return base_path() . '/public_html';
});
}
This command gives me an error when I type php artisan storage: link
In Filesystem.php line 330:
symlink(): No such file or directory
Content-type: text/html; charset=UTF-8
my filesystem.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
],
],
'links' => [
public_path('storage') => storage_path('app/public'),
],
When I go to the public_html folder And I run the rm storage command Gives me an error:
rm: cannot remove ‘storage’: Is a directory
I even manually deleted the storage folder and ran php artisan storage: link again And gives the error again In Filesystem.php line 330:
symlink (): No such file or directory
Content-type: text / html; charset = UTF-8
Please or to participate in this conversation.