Allow send image other than jpeg

If try to send image other than jpeg, it will return imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error. Checking file extension to split to seperate formats.