1 year ago

#337638

test-img

Salar Pro

Laravel 8 Image source not readable, on Intervention Image resize (Shared hosting)

I'm using Laravel 8. I was working on my machine (locally), after deploying it on the Shared hosting (my case Bluehost), I have moved the project to the root of my hosting, And I created a subdomain to my Laravel project, and I moved the public folders file to the subdomain folder. I have executed the php artisan storage:link, everything works fine, even the images are uploaded, but the problem is when I use the Intervention Image to resize the image it shows

Intervention\Image\Exception\NotReadableException
Image source not readable

The code:

$imageName = $request['image']->store('uploads/brand', 'public');
Intervention\Image\Facades\Image::make(public_path("storage/{$imageName}"))->fit(1024, 1024)->save();

I have tried some solutions, but no result, the error kept the same

The solutions that I tried:

1- config/filesystems.php

'links' => [
        base_path('/public_html/storage') => storage_path('app/public'),
    ],

2- I tried to specify the public path manually.

3- https://stackoverflow.com/a/39971026/5862126 the error is

Intervention\Image\Exception\NotWritableException
Can't write image data to path (/home4/ctwotec3/laravel_market/public/uploads/4386300.jpg)

Edited 1: HTML Form code

@extends('layouts.app')

@section('content')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="container">

    <form action="/brand" enctype="multipart/form-data" method="POST">
        {{ csrf_field() }}

        <div class="card">
            <div class="card-header">
                <h1 class="text-center">New Brand</h1>
            </div>
            <div class="card-body">
                <div class="col-10 offset-1">


                    {{-- Name English --}}
                    <div class="row">
                        <div class="row mb-3">
                            <label for="name_en" class="col-md-4 col-form-label text-md-end">Name English</label>

                            <div class="col-md-6">
                                <input id="name_en" type="text"
                                class="form-control @error('name_en') is-invalid @enderror" name="name_en"
                                value="{{ old('name_en') }}" autocomplete="name_en" autofocus>
                                
                                @error('name_en')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>
                    </div>
                    
                    {{-- Name Kurdish --}}
                    <div class="row">
                        <div class="row mb-3">
                            <label for="name_ku" class="col-md-4 col-form-label text-md-end">Name Kurdish</label>
                            
                            <div class="col-md-6">
                                <input id="name_ku" type="text"
                                class="form-control @error('name_ku') is-invalid @enderror" name="name_ku"
                                value="{{ old('name_ku') }}" autocomplete="name_ku" autofocus>
                                
                                @error('name_ku')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>
                    </div>
                    
                    {{-- Name Arabic --}}
                    <div class="row">
                        <div class="row mb-3">
                            <label for="name_ar" class="col-md-4 col-form-label text-md-end">Name Arabic</label>
                            
                            <div class="col-md-6">
                                <input id="name_ar" type="text"
                                class="form-control @error('name_ar') is-invalid @enderror" name="name_ar"
                                value="{{ old('name_ar') }}" autocomplete="name_ar" autofocus>
                                
                                @error('name_ar')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>
                    </div>
                    
                    
                    
                    
                    {{-- Single image --}}
                    <div class="row">
                        <div class="row mb-3">
                            <label for="image"
                                class="col-md-4 col-form-label text-md-end">{{ __('Item image') }}</label>

                            <div class="col-md-6">
                                <input id="chooseFile" type="file" class="form-control" name="image" @error('image')
                                    is-invalid @enderror accept=".jpg,.jpeg,.png">

                                @error('image')
                                <strong style="color: red">{{ $message }}</strong>

                                @enderror

                            </div>
                        </div>
                    </div>

                   
                </div>
            </div>
        </div>

        <div class="d-flex justify-content-center">
            <button class="btn btn-primary mt-3 mb-3 float-end w-75 ">submit</button>
        </div>
    </form>
</div>
@endsection

Edited 2: here is the path of the uploaded image on the server, that the Intervention Image can't read it

/home4/ctwotec3/laravel_market/public/storage/uploads/brand/r0kBFdXcxCg59WKIwmNsIwq16g30mWs4LZLxWSeT.jpg

laravel

laravel-8

image-resizing

shared-hosting

0 Answers

Your Answer

Accepted video resources