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

juvpengele's avatar

Import an excel file in database driver queue

I wan to read a file in queue (QUEUE_DRIVER=database), when i dispatch a job from the controller to queue, and pass the file path as parameter, the job start to run, but when open a file, the code throw an ErrorException as follow:

[2019-06-06 15:17:09] local.ERROR: Could not open /home/juvenal/Lab/Pro/support-stat/storage/imports/ENNYO9iwInnClO5r9r3mtVJ1camwKKzU9wkkylrC.xlsx for reading! File does not exist.

When I set the queue_driver = sync, the job can open the file the path without an error.

this is my code in the controller

$path = request()->file("cdr_file")->store("imports");
    $absolutePath = storage_path($path);
    StoreCdr::dispatch($absolutePath);

How could I open a file in a queue driver ?

0 likes
2 replies
Punksolid's avatar

Hi @juvpengele you checked that the file really was imported there /home/juvenal/Lab/Pro/support-stat/storage/imports/ and with that name?

doesn't look that the error is in the queue driver

Snapey's avatar

You need to move the file from the import location to somewhere else in your storage.

When you upload a file, php keeps it in a temporary location.

At the end of the request cycle it clears the temporary files.

With sync queue you are processing the file as part of the same request cycle.

With async the cleanup has occurred before you get to process the file.

Just move the file as you would do if uploading a photo

1 like

Please or to participate in this conversation.