1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
void _send(char* fileTosend)
{
FILE *file;
char *buffer;
unsigned long fileLen;
file = fopen(fileTosend, "rb");
if (!file)
{
printf("%s\r\n", "File not found");
}
fseek(file, 0, SEEK_END);
fileLen=ftell(file);
fseek(file, 0, SEEK_SET);
buffer = new char[fileLen];
fread(buffer, fileLen, 1, file);
char size[MAX_PATH];
sprintf(size, "%i", fileLen);
fclose(file);
send(sConnect, size, MAX_PATH, 0); //send file size
send(sConnect, buffer, fileLen, 0); //send binary
free(buffer);
}
|