Fix: Beleg-Upload in Bank-Zuordnung speichert Datei jetzt im korrekten public/static/uploads-Pfad
This commit is contained in:
parent
b1be01ff86
commit
d31e5afa57
1 changed files with 13 additions and 11 deletions
|
|
@ -247,19 +247,21 @@ class BankController
|
|||
}
|
||||
|
||||
$ext = $allowedMime[$mime];
|
||||
$hash = hash_file('sha256', $file['tmp_name']);
|
||||
$filename = $hash . '.' . $ext;
|
||||
$dir = BASE_DIR . '/storage/belege/';
|
||||
if (!is_dir($dir)) mkdir($dir, 0755, true);
|
||||
$dest = $dir . $filename;
|
||||
if (!file_exists($dest)) {
|
||||
move_uploaded_file($file['tmp_name'], $dest);
|
||||
}
|
||||
$belegNr = Beleg::generateBelegNr();
|
||||
$year = date('Y', strtotime($transaction['wertstellung']));
|
||||
$relDir = "static/uploads/{$year}/{$belegNr}";
|
||||
$absDir = dirname(__DIR__, 2) . "/public/{$relDir}";
|
||||
if (!is_dir($absDir)) mkdir($absDir, 0755, true);
|
||||
|
||||
$storagePath = "{$relDir}/original.{$ext}";
|
||||
$absPath = dirname(__DIR__, 2) . "/public/{$storagePath}";
|
||||
move_uploaded_file($file['tmp_name'], $absPath);
|
||||
$hash = hash_file('sha256', $absPath);
|
||||
|
||||
$belegId = Beleg::create([
|
||||
'beleg_nr' => Beleg::generateBelegNr(),
|
||||
'beleg_nr' => $belegNr,
|
||||
'filename' => $file['name'],
|
||||
'storage_path' => 'storage/belege/' . $filename,
|
||||
'storage_path' => $storagePath,
|
||||
'mime_type' => $mime,
|
||||
'file_hash' => $hash,
|
||||
'beleg_datum' => $transaction['wertstellung'],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue