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
|
|
@ -246,20 +246,22 @@ class BankController
|
||||||
View::redirect("/bank/$id", 'Nicht erlaubtes Dateiformat.', 'error');
|
View::redirect("/bank/$id", 'Nicht erlaubtes Dateiformat.', 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
$ext = $allowedMime[$mime];
|
$ext = $allowedMime[$mime];
|
||||||
$hash = hash_file('sha256', $file['tmp_name']);
|
$belegNr = Beleg::generateBelegNr();
|
||||||
$filename = $hash . '.' . $ext;
|
$year = date('Y', strtotime($transaction['wertstellung']));
|
||||||
$dir = BASE_DIR . '/storage/belege/';
|
$relDir = "static/uploads/{$year}/{$belegNr}";
|
||||||
if (!is_dir($dir)) mkdir($dir, 0755, true);
|
$absDir = dirname(__DIR__, 2) . "/public/{$relDir}";
|
||||||
$dest = $dir . $filename;
|
if (!is_dir($absDir)) mkdir($absDir, 0755, true);
|
||||||
if (!file_exists($dest)) {
|
|
||||||
move_uploaded_file($file['tmp_name'], $dest);
|
$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([
|
$belegId = Beleg::create([
|
||||||
'beleg_nr' => Beleg::generateBelegNr(),
|
'beleg_nr' => $belegNr,
|
||||||
'filename' => $file['name'],
|
'filename' => $file['name'],
|
||||||
'storage_path' => 'storage/belege/' . $filename,
|
'storage_path' => $storagePath,
|
||||||
'mime_type' => $mime,
|
'mime_type' => $mime,
|
||||||
'file_hash' => $hash,
|
'file_hash' => $hash,
|
||||||
'beleg_datum' => $transaction['wertstellung'],
|
'beleg_datum' => $transaction['wertstellung'],
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue