Joey.Z
Joey.Z

Reputation: 4790

Upload pics to a server using c++

I'm trying to upload a photo to one of our server in C++, the following is an excerpt of my testing code

//in main
ifstream fin("cloud.jpg");
ofstream fout("cloudcpy.jpg");

string data;
while ( fin )
    fin >> data;
fout << data;
fin.close();
fout.close();

return 0;

But the output file is not a copy, much more smaller than the original one. Anything wrong in my code?

Upvotes: 0

Views: 840

Answers (2)

oldmonk
oldmonk

Reputation: 739

You need use 3rd party library. Please try libcurl

Upvotes: 1

jgmao
jgmao

Reputation: 147

You may not use string as the data type. Since JPEG file is not a textfile. Please try to use primitive type such as unsigned char or unsigned int to do it.

Upvotes: 0

Related Questions