The code flow should be changed in the way if thre is an upload file error program should not reach this block.