How to save the image of a node to the custom directory programmatically? I have a cck image field and I have the "uploads" directory in the files folder.

I want the images of these nodes are saved to the directory with the name of the node id and then the image file. Suppose if the node id is 4 then the image should be saved to the following directory.

files/uploads/4/filename


the directory with the name of "4" should be created programmatically.

Which hook should I use for this and how to achieve this? Any one who have some idea?
You have to use following module https://drupal.org/project/filefield_paths . then you can add tokens for it .