c++ - Corrupted Binary Files after Transfer libcurl -
I am using a binary file (.exe) with libcurl with FTP, and saving it to a local file I am The problem is that after transferring the file, it is replaced and now it is not a valid Win32 application, and does not run. Here's how I am doing this:
curl * curl; Curl = curl_easy_init (); FILE * f = fopen ("C: \\ blah.exe", "w"); If (curl) {curl_easy_setopt (curl, CURLOPT_URL, "ftp://ftp.mysite.com"); Curl_easy_setopt (curl, CURLOPT_USERPWD, "blah: blah"); Curl_easy_setopt (curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); Curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, NULL); Curl_easy_setopt (curl, CURLOPT_WRITEDATA, & amp; F); } Other {fclose (f); Return CURL_EASY_INIT_FAIL; } Fclose (f);
The file is written but the bigger the FTP server. Like I said, the attempt to run it is not a valid Win32 application error in "% 1". Did I forget to set an option or something?
You forgot the binary flag This is the correct code:
FILE * F = fopen ("C: \\ blah.exe", "wb");
Comments
Post a Comment