Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

How to remove attachments ?

edited October 2013 in General Discussions
How an attachment can be removed without deleting the ticket ?

I was going to migrate my host and i found that the database size is around 1.6GB ! checked it and found that 1.54GB is related to 2 tables which hold attachments. Now migrating such huge DB is not an easy work !

Now i have two questions :

1. Is there anyway to delete attachments without deleting tickets so i can make the database smaller ?
2. Are advantages of keeping attachments in DB more than its disadvantages ?

Thanks in advance.


  • yes i like to delete some of this attachment also 
  • You can simply truncate those tables if you no longer require the attachments.

    I've tested it, simply phpMyAdmin or mysql client,
    "TRUNCATE TABLE ost_file"
    "TRUNCATE TABLE ost_file_chunk"
    "TRUNCATE TABLE ost_attachment"
    "TRUNCATE TABLE ost_ticket_attachment"

    Returning to tickets view, it simply doesn't see the attachments at all, they were never there apparently. ;-)

    If that is your desired outcome, fire away!

    If you wish to preserve the attachments, then you will need to get more creative. I would suggest keeping attachments for active/open tickets.. especially if you are processing orders via tickets.

    Seems the kb article attachments and possibly other attachments may also be stored as files.. so

    Advantages? I'm not 100% on this one, I find it is technically "more secure" than file-system attachments, but it is definitely slower. The system is easier to upgrade and backup as all data/settings/config is in the database, apart from the initial ost-config.php file you can simply replace everything else, your filesystem usage is minimal, so its great for a server with low storage space, however as you know, the database size is considerable on larger installs.. so its a tradeoff. If your database was limited in size, then this could definitely go over your limits.. for instance, GoDaddy definitely limits database size!

  • How can I delete a particular attachment within a ticket? For example, if a ticket have 3 attachments, how can I just delete a particular one?
  • edited December 2014
    I recommend to use a tool like phpMyAdmin for the following:
    - Lookup the attachment id in the table "ost_file", e.g. ID = 26 (via the name you should be able to find the correct attachment which you like to delete)
    - Search all rows with this attachment id (e.g. attach_id = 26) in the table "ost_ticket_attachment" and delete the rows there
    - Now in the ticket thread, the attachment should be gone, but its still in the database, so:
    - Finally delete the attachment itself (e.g. ID = 26) from the "ost_file" table

    PS: Please don't hijack a 1 year old discussion the next time. Instead open a new discussion and maybe add a link to the old discussion when necessary. Also make sure to read our sticky discussion:
This discussion has been closed.