tommasoKuhn's avatar

Error filesystem folder root

Hi, The software I’ve been tasked with fixing carries a bug that has persisted across several versions, starting from 5.8 (it’s now at version 8, and we’ll update it to version 11).

Files are randomly saved in two different folder locations, using the same exact function and the same account (but from different computer stations).

The folder structure is as follows (all with 755 permissions):

storage/app/archive/pdf/...
						4444/...
							/523/2024-11-10.pdf
							/43/2023-10-11.pdf
						14/...
							/323/2022-11-10.pdf
							/12/2023-10-11.pdf
						43030/...
							/44/2022-11-10.pdf
							/292/2023-10-11.pdf

storage/app/...
		4444/...
			/113/2004-01-20.pdf
			/55/2003-10-21.pdf
		14/...
			/1123/2002-12-20.pdf
			/1212/2003-11-21.pdf
		43030/...
			/144/2002-03-15.pdf
			/1283/2003-10-31.pdf

.env:

CERT_DIR=archivio/cert/

filesystem.php:

'default' => 'local',

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

The code is as follows:

$fileName = $certificate->nome_file.'.'.$file->extension();
$file->storeAS(env('CERT_DIR').'/'.$certificate->user_id.'/'.$certificate->strumento_id, $fileName);

With a dd() test, I discovered a possible cause. The resulting path is:

archive/pdf//4459/47964

where there is a double //. According to my research, in some filesystems, this could be interpreted as an absolute path, which might be treated as a save operation in the "storage/app" root directory.

Since I’m unable to reproduce the error and cannot halt the client’s production system, I’m asking for assistance.

Thank you!

0 likes
0 replies

Please or to participate in this conversation.