I have an arduino mega 2560 with ethernet shield at a remote place. So, I would like to know is there any possibility of uploading the sketch through the internet and not using a cable?
I did read through the below approaches. I do not know how effective is the first approach and with regards to the second, it uses a Node MCU and not an arduino mega.
How To Upload A Sketch To Your Arduino Via A Network | Freetronics
#32 Internet of Things with ESP8266 #4: Upload Programs Over the Air (OTA) - YouTube
I'm not sure what you mean by "not using a cable". You have an Ethernet shield so I'd have to assume it's connected to an Ethernet cable.
This is the one you want:
For my NodeMCU and other ESP8266 based projects I normally set up the ArduinoOTA functionality. Very convenient - can update over WiFi (that's still not over Internet, just my LAN, even though that's connected to the Internet as well).
For the ArduinoOTA to work, it's important that you have enough memory available: your new sketch must be uploaded while the original sketch is still there, so typically both should be less than half the total memory in size. So with the ESP8266 I have to make sure my sketches don't go over 2 MB (never got over 430 kB so far, so no problem there). For the AVR processors those numbers would be much lower.