FTP Upload w/ WinSock
Hello all. I'm trying to upload a file to my FTP server using WinSock. Here's my code for downloading a file, which works fine:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
file.open(command, ios::out|ios::binary);
char singleBuffer[1];
int bytes(0);
stringstream stream;
while(recv(FTPsocket2, singleBuffer, sizeof(singleBuffer), 0))
{
file << singleBuffer[0];
++bytes;
if(bytes%1000 == 0)
{
stream << bytes/1000;
Respond(HOSTsocket, "\u001B[2JDownloading file... "+stream.str()+" kb transferred.");
stream.str("");
}
}
file.close();
|
...and here's what I have for uploading a file:
1 2 3 4 5 6 7 8 9 10 11
|
file.open(command, ios::in|ios::binary);
char singleBuffer[1];
while(!file.eof())
{
file >> singleBuffer[0];
send(FTPsocket2, singleBuffer, sizeof(singleBuffer), 0);
}
file.close();
|
I tried uploading a gif, but it turns out slightly larger than the original file and corrupted.
Topic archived. No new replies allowed.