Gabotronix's avatar

Issue resizing image with laravel intervention package

Hi everybody, I'm trying to resize an image I'm uploading with vue2-editor, I'm doing this since images uploaded with vue2-editor take too much space (image original size) and destroy my layout... I'm using intervention package to do this but I'm getting the following error:

message fopen(C:\xampp\htdocs\Costadog6\public\uploads): failed to open stream: Permission denied
exception   ErrorException
file    C:\xampp\htdocs\Costadog6\vendor\league\flysystem\src\Adapter\Local.php

This is the code in my controller method:

public function uploadFile(Request $request)
    {
        if($request->hasFile('image')){ 
            $uploadFile = $request->file('image');
            $filename = str_random(6).'.'.$uploadFile->extension();

            $image_resize = Image::make($uploadFile);              
            $image_resize->resize(800, 400);
    
            $uploadFile->storeAs('uploads', $image_resize);
            
            $url = '/uploads/'.$filename;
            
            return response()->json([
                'url' => $url,
            ]);
        }

        return response()->json([
            'url' => config('globals.dummy_image'),
        ]);
    }

Any idea what I'm doing wrong?

Also, is there a way to apply css rules to an image uploaded with an rich editor?

0 likes
1 reply

Please or to participate in this conversation.