Thanks for this reply. Its working.
Here we are dividing the all images in two part then we are saving into database.
Suppose as per excel sheet has 8 images, if suppose row no.2 and 3 is blank in flag column then this code will not save data as per id.