0

Here is the error screen

Spatie\Browsershot\Exceptions\CouldNotTakeBrowsershot The given path F:\xampp\htdocs\testcover\public/uploads/ did not contain an extension. Please append an extension

I received this error when trying to save an HTML file as an Image file using Spatie BrowerShot. How can it be fixed. Thanks everyone

1 Answers1

0

You are mixing windows paths with \ as the separator with linuxs / separator, add your path to the public_path() call and it should work as intended.

$destination = public_path('uploads');
mrhn
  • 17,961
  • 4
  • 27
  • 46
  • Browsershot::url('https://spatie.be/docs/browsershot/v2/usage/creating-pdfs') ->savePdf(public_path('uploads/' . Str::uuid() . '.pdf')); this didn't work for me – Md Rashedul Islam May 30 '23 at 09:43
  • thinking something like this will help savePdf(public_path('uploads') . '\' . Str::uuid() . '.pdf') – mrhn May 30 '23 at 09:56
  • sorry. this still not working. currently getting this error (i have changed filename as static for testing) For some reason Chrome did not write a file at `/MY_PROJECT_DIR/public/uploads/test.pdf`. Command ======= [] Output ====== – Md Rashedul Islam May 30 '23 at 10:08
  • currently i am using ubuntu 22.04 and node 14 (nvm using for node management) – Md Rashedul Islam May 30 '23 at 10:09
  • erm what is the error? if i remember vaguely there is some problems locally with having the right access rights to actually save the files. Have you tried running it on a proper setup server etc.? – mrhn May 30 '23 at 10:13
  • Yes. on my local machine, js version working properly. I just trying to write code on laravel. my base project is on laravel. – Md Rashedul Islam May 30 '23 at 10:42
  • i am not sure that, i am getting issues because of lack permission of my chromium (chromium does not have access to save files on my local) – Md Rashedul Islam May 30 '23 at 10:47