diff --git a/inventory/routes/images.py b/inventory/routes/images.py index 98da13b..18f1117 100644 --- a/inventory/routes/images.py +++ b/inventory/routes/images.py @@ -79,7 +79,10 @@ def delete_image(image_id): if not image: return jsonify({"success": False, "error": "Image not found"}) - abs_path = os.path.join(current_app.static_folder, image.filename.replace("\\", "/")) + rel_path = posixpath.normpath(str(image.filename)) + static_dir = str(current_app.static_folder) # appease the gods + abs_path = os.path.join(static_dir, rel_path) + if os.path.exists(abs_path): os.remove(abs_path)