Jump to content

Forum Attachment System


doddsey_65

Recommended Posts

I need to make an attachment system for my forum but i have a big issue. When a user adds an attachment they are added to the server there and then(the way i want it to be so i can have progress bars and such). Then when a user submits their post the content and attachmnet names are added to the database. Simple. But what happens when a user decides not to continue with the post? The attachments have already been added to the server but they arent being used. One thing i can think of is to run a query which checks which attachments are on the server and cross references them with the names in the database. If they are on the server but not in the database then delete the files. However that seems to be quite an intensive way of doing things and adds yet another query to each page load. Any advice or ideas on this?

Link to comment
Share on other sites

Where are the attachments saved?

 

I'd put then into a first temp folder and then when the user submits his post the code that adds to the DB can also move the attachment to a permanent location.

 

All stuff left in the first temp folder are the attachments that were not followed up with a post. Easy to handle and delete or what ever. :D

Link to comment
Share on other sites

Where are the attachments saved?

 

I'd put then into a first temp folder and then when the user submits his post the code that adds to the DB can also move the attachment to a permanent location.

 

All stuff left in the first temp folder are the attachments that were not followed up with a post. Easy to handle and delete or what ever. :D

 

Your still uploading content to the folder.

 

 

OP, I think the "Cancel" / "Delete" button can trigger a function that will check if there were any attachments made, find them, and delete them. simple.

Link to comment
Share on other sites

you suggest a button in the admin section that will delete all attachments that arent being used?

 

Yeah, but if you dig a little deeper you will get some more problems such as if they close their browser and don't bother to even click cancel.

 

Heres what I would do...

 

If a user decides to upload an attachement I will store in a database table, and each attachement has a POST ID which is assigned to it. When they click submit, you can have boolean field which confirms if the post has been submitted or not, if it has then make sure you update the attachement in the table and set the attachement_submitted field to true. You can also delete the attachement if they click cancel, and run a cron job to everyday at a certain time which will check for all attachement who have the attachement_submitted field set to false.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.