开发者

Attaching a file to a post

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?

Attaching a file to a post


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜