0

i use laravel backpack and i try to upload images. in local working. but in server the image uploaded to public, and not displaying in site i try change disk and in fileSystem but nothing changed

//model

 public function setPosterAttribute($value)
    {
        $attribute_name = "poster";
        $disk = "public";
        $destination_path = "uploads/products/posters";

        // if the image was erased
        if ($value==null) {
            // delete the image from disk
            \Storage::disk($disk)->delete($this->{$attribute_name});

            // set null in the database column
            $this->attributes[$attribute_name] = null;
        }

        // if a base64 was sent, store it in the db
        if (starts_with($value, 'data:image'))
        {
            // 0. Make the image
            $image = \Image::make($value);
            // 1. Generate a filename.
            $filename = md5($value.time()).'.jpg';
            // 2. Store the image on disk.
            \Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());
            // 3. Save the path to the database
            $this->attributes[$attribute_name] = $destination_path.'/'.$filename;
        }
    }

//fileSystem

    'public' => [
        'driver' => 'local',
        'root' => public_path(),
        'visibility' => 'public',
    ],

1 Answer 1

3

Well, in your public array, the root is set to public_path() which is the path to your public folder. If you want to change that, you should should your configuration to the following:

'public' => [
    'driver' => 'local',
    'root' => base_path('public_html'),
    'visibility' => 'public',
],
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.