I want to encode a file it may be image or any pdf and send it to server. Which type of Encoding and decoding I have to follow. (Both server and client is in our company. we
UTF-8 is a text encoding - a way of encoding text as binary data.
Base64 is in some ways the opposite - it's a way of encoding arbitrary binary data as ASCII text.
If you need to encode arbitrary binary data as text, Base64 is the way to go - you mustn't try to treat arbitrary binary data as if it's UTF-8 encoded text data.
However, you may well be able to transfer the file to the server just as binary data in the first place - it depends on what transport you're using.