Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

Why do I get error uploading file with dompdf?

In laravel app I download generated pdf file into temp subdirectory, but I got error :

The filename and the fallback cannot contain the "/" and "\" characters.

With code:

        $save_to_file               =  substr(Session::getId(), 0,20) . '-' . $filename_to_save;
        $save_to_file_full_path     = $tmp_dest.$save_to_file;

        \Log::info(  varDump($save_to_file, ' -10 $save_to_file::') );
        \Log::info(  varDump($save_to_file_full_path, ' -1 $save_to_file_full_path::') );
        \Excel::download(new HostelsByIdExport(array_keys($this->confirmActionModalHostelsList)), $save_to_file_full_path);
        // ERROR points to line above

        return response()->download($save_to_file_full_path, $save_to_file);//->deleteFileAfterSend(true);

checking in log path of uploaded file :

[2021-10-30 15:03:33] local.INFO: scalar => (string) : -10 $save_to_file:: : eML9aWIzeqN7qiTsTqgl-hostels-export.pdf  
[2021-10-30 15:03:33] local.INFO: scalar => (string) : -1 $save_to_file_full_path:: : /mnt/_work_sdb8/wwwroot/lar/Hostels4J/storage/app/public/tmp/eML9aWIzeqN7qiTsTqgl-hostels-export.pdf  

where /mnt/_work_sdb8/wwwroot/lar/Hostels4J -is root dir of my app. Seems I have valid name of file with path where it has to be uploaded... Which way is correct ?

"barryvdh/laravel-dompdf": "^0.9.0",
"dompdf/dompdf": "1.0.0",
"laravel/framework": "^8.66.0",

Thanks!

0 likes
1 reply

Please or to participate in this conversation.