Ok,
So, I have a social networking website where users can share a post and now i am implementing attachment feature so that users can attach files to the post. I use uploadify in order to upload files to the server. So, my current logic is, when user browses the file and clicks attach as in the attached image, the files are uploaded to a temporary directory in the server and when the post is actually shared, the files are moved to correct upload directory and database is updated accordingly. But my logic goes wrong when the user click attach, so, his files are uploaded to the server, and he quits the application without actually sharing the post. So, those files will be on the ser开发者_运维技巧ver unnecessarily. How can I modify my logic to preven this from happening?
Maybe you can add a flag in database like "shared" defaults to 0 when the user clicks the share button you can run an update setting it to 1.
Add a cronjob getting all uploads with "shared" = 0 and timestamp > 1 day :)
You would need to use CRON task to execute a script that checks if files are associated with any published/saved content. If not it deletes them from your filesystem.
精彩评论