← Back to all posts
Image Uploads: Getting CRUD Right the Second Time
{"id":1,"name":"Tech","slug":"tech","created_at":"2026-09-10T01:46:36.000000Z","updated_at":"2026-09-10T01:46:36.000000Z"}

Image Uploads: Getting CRUD Right the Second Time

By Nazif · 10 Sep 2026

Adding image uploads to posts was straightforward the first time around, but I hadn't thought about what happens to old files when an image gets replaced or a post gets deleted. Without cleanup logic, uploaded files just pile up in storage forever, unused. This time, replacing an image now deletes the old file first, removing an image through the dashboard actually deletes it from disk, and deleting a post cleans up its image too. Nothing gets left behind as an orphaned file. It's the kind of detail that's easy to skip when a feature "just works," but matters a lot once you start thinking about a site running long-term in production.