Complete function of image uploading.