How to convert binary file to its original format

Hi.

I am sending file to server as binary
I read file from clinet store in buffer and send it
In Server I open a file, recv it and write to file.

So assume I send a myFile.txt from client to local server. But My server is accepting the file as bin. If client again wants to download it as it is in original format how can I do it?

Thanks
A file is simply an array of bytes, it doesn't have format by itself. The data contained in it is interpreted in one way or another by the programs that read it.

A "binary" transfer means that the contents of the file are transferred verbatim, without any special processing. I.e. what you put in one end is what you get at the other end.
A "text" transfer, on the other hand, may do some processing when the source and destination platforms are different so the file can be read as text at the destination. For example, when transferring a file as text from Windows to Unix through FTP, Windows newlines ("\r\n") are converted to Unix newlines ("\n").

Obviously, transferring non-text files as text may destroy data. For example, the sequence "\r\n\n" may get uploaded as "\n\n" and then downloaded as "\r\n\r\n". If the file is read as text, this sequence still means "two newlines". Otherwise, the file may have been corrupted by the transfer.
Transferring text files as binary is always a non-destructive process.
Topic archived. No new replies allowed.