Attachment_fu and mysql (server has gone away)

I have a problem with my hosting “hostgator”

In my site i have a section for photos upload.
For manage it i use attachment_fu.
In the action of upload i do some simple query.

If the file to upload is smaller than 1mb there isnt any problem

but if it is bigger than 1 mb about i receive an error:

mysql error server has gone away.

i wrote to hostgator. they responsed me with:

All MySQL connections open for more than 15 seconds are killed off once
a minute. Your script needs to be modified so the MySQL connection is
opened just prior to the query actually being run

How i can to open mysql connection only when i do query for this action?
thanks