problem in uploading attachment to custom directory

If I remember right you need to chdir() into your custom uploads directory (before saving anything there) so that paths are correctly processed and saved in meta.