Merge pull request #12351 from snipe/fixes/check_filename_has_value_before_delete

Check that the `$use_db_field` has a value before attempting a delete
This commit is contained in:
snipe 2023-01-13 11:29:31 -08:00 committed by GitHub
commit 021e54adaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -146,7 +146,7 @@ class ImageUploadRequest extends Request
}
// Remove Current image if exists
if (Storage::disk('public')->exists($path.'/'.$item->{$use_db_field})) {
if (($item->{$use_db_field}!='') && (Storage::disk('public')->exists($path.'/'.$item->{$use_db_field}))) {
\Log::debug('A file already exists that we are replacing - we should delete the old one.');
try {
Storage::disk('public')->delete($path.'/'.$item->{$use_db_field});