title: Attaching a file to a post
body: <p>Ok,</p>
  
  <p>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 server unnecessarily. How can I modify my logic to preven this from happening?<img src="https://i.stack.imgur.com/STY39.png" alt="enter image description here"></p>