laravel-dompdf icon indicating copy to clipboard operation
laravel-dompdf copied to clipboard

Laravel Unable to create directory: /tmp

Open HashmatWaziri opened this issue 2 years ago • 6 comments

` $pdf = PDF::loadView('education::classes.reports.pdf.student.memorization', $data)->setPaper('a4');

    // Get the current time, but only the hour, minute, and second

    // Define file path and name without the time component

    $filename = "student_memorization_report_{$month}_{$year}.pdf";

    $filePath = storage_path('app/public/reports/' . $filename);



    // Check if a file with the same name already exists, delete if it does

    if (file_exists($filePath)) {

        unlink($filePath);

    }

    $pdf->save($filePath);`

dompdf error

HashmatWaziri avatar Nov 25 '23 12:11 HashmatWaziri

@ericvanjohnson @jdavidbakr @zaherg @luke83 , Wanted to follow up on this matter. thanks.

HashmatWaziri avatar Nov 26 '23 14:11 HashmatWaziri

@jdavidbakr @zaherg @luke83 @ericvanjohnson , wanted to follo up on this

HashmatWaziri avatar Dec 01 '23 14:12 HashmatWaziri

I'm unclear why you tagged me? Looks like it may be a filesystem issue, does the /tmp directory exist in your environment and is it writable by the web service?

jdavidbakr avatar Dec 01 '23 15:12 jdavidbakr

I appologize if wrongly tagged but yeah it is writable by the web service . I am using ubunto for production. here is the details of the tmp folder : drwxrwxrwx 11 root root 409600 Dec 2 08:10 tmp I already changed the root root to the web services one but still got error. Anather point is that I already changed the "temp_dir" => storage_path('app/dompdf_temp'), of the dompdf but it is not reflected as it keeps giving me that error

HashmatWaziri avatar Dec 02 '23 07:12 HashmatWaziri

The same here. Overriding the temp_dir in dompdf.php does override the config variable but the loadHTML method is still pointing to /tmp directory. Is there any method or config to fix this ?

ronlinet avatar Aug 22 '24 14:08 ronlinet

This is what does the job in my case $pdf->setOptions(['logOutputFile' => storage_path('app/dompdf/' . 'index.html')] )

ronlinet avatar Aug 22 '24 16:08 ronlinet