diff --git a/content.py b/content.py index b6c631981..23dfc3b3b 100644 --- a/content.py +++ b/content.py @@ -932,6 +932,16 @@ def saveMediaInFormPOST(mediaBytes, debug: bool, Returns the filename and attachment type """ if not mediaBytes: + if filenameBase: + # remove any existing files + extensionTypes = getImageExtensions() + for ex in extensionTypes: + possibleOtherFormat = filenameBase + '.' + ex + if os.path.isfile(possibleOtherFormat): + os.remove(possibleOtherFormat) + if os.path.isfile(filenameBase): + os.remove(filenameBase) + if debug: print('DEBUG: No media found within POST') return None, None