mstdmstd
3 months ago
116
2
Laravel

How to save on disk file generated with spatie/browsershot

Posted 3 months ago by mstdmstd

Hello, In my laravel 5.8/blade/jQuery v3.3.1 app with https://github.com/spatie/browsershot plugin I managed in my kubuntu 18 to upload my file with path

     $save_to_file= '/home/username/Downloads/file.pdf';
     Browsershot::html(htmlspecialchars_decode($pdf_content))
         ->showBackground()
         ->save($save_to_file);

But to run it without error I had to run in my console :

    sudo chmod -R 777 /home/username/Downloads/

otherwize I got error access permission

  1. I wonder if there is a way to escape this error on client's OS, as I can not run
    sudo chmod -R 777 /home/username/Downloads/

on client's site. I search OS independently decision

  1. Can you advice some Javascript/Jquery script to open "SaveAs" dialog for choosing of saving location? And maybe somehow to check if app has not write access to info user?

Thanks!

Please sign in or create an account to participate in this conversation.