Saving images and thumbnail images

i want to save original image and that orignal image thumbnail also how can i do that

any sample code