I'm trying to allow image upload to a web server via a web form (aware of the security risks). My code works great for text files but I am getting stuck on eof in image files which I know is not a special character in image files so cannot be used as a delimiter.
I've tried getline(cin, formstr, '\0');
which, of course, fails at the first \0 in the file. I've tried other delimiters and have moved a little further into the file but never to the end. I think I'm going about this incorrectly with getline.
Maybe I need to get the file in binary, i.e. ifstream thefile("/path/to/file.jpg", ios::binary);
but I don't have the file name until I receive the data, and I can't use a string variable for filename anyway. Also, I've received all the data I'm going to get at this point.
A push in the right direction would be appreciated, thanks!