I am having a similiar issue, likely on the same page, but now we have updated to MySQLI. Page is attached.
Line # 122 of update query or the obvious upload params at the top of the page.
I have revised the upload directory from 2022 to 2023 and if the record is updated it changes the file directory to 2023 resulting in a broken path IF the original record was created using the 2022 file directory AND a new file is not uploaded.
Right now the user has to go back and upload the flyer again and we end up with it BOTH in the 2022 directory and the 2023 directory and an unpleasant experience for the user.