0
votes

I'm triying to save an image using laravel intervention

If I use this method it works fine

$route = 'img/' . $domain . '.png';
$img->save(public_path($route));

But I want to save this in a new folder with the domain name $domain

I tried to use this

    $route = 'img/' . $domain . '/' . 'favicon.png';
    $img->save(public_path($route));

But I get this error

Can't write image data to path (D:\Programas\laragon\www\google-places-ranking\public\img/testfaviconnew/favicon.png)

How can I solve it?

1
Check if there are file permission issues. You can also try $route = 'img' . DIRECTORY_SEPARATOR . $domain . DIRECTORY_SEPARATOR . 'favicon.png'; - Donkarnash
thanks, I solved it, thanks for the idea - André Cuellar Avaroma

1 Answers

0
votes

I solved using this,

thanks to @Donkarnash for the idea using DIRECTORY_SEPARATOR

\File::makeDirectory('img' . DIRECTORY_SEPARATOR . $domain);
$route = 'img' . DIRECTORY_SEPARATOR . $domain . DIRECTORY_SEPARATOR . 'favicon.png';
$img->save(public_path($route));
return $route;

this method creates a new folder :)