Using VC++6 on XP, I am trying to upload a small jpeg file to a script that looks like:
PHP Code:
<form method="post" enctype="multipart/form-data" action="upload.php">
File: <input type="file" name="file" size="40"> <br>
Name: <input type="text" name="name" size="40"> <br>
<input type="submit" value="send" name="submit"> <br>
</form>
The code I am made is this:
Code:
#include <curl.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
CURL *curl;
CURLcode res;
HttpPost* post = NULL;
HttpPost* last = NULL;
curl = curl_easy_init();
if(curl)
{
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "file",
CURLFORM_FILE, "C:\\rect.jpg",
CURLFORM_END);
curl_formadd(&post, &last,
CURLFORM_COPYNAME, "name",
CURLFORM_FILE, "rect.jpg",
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_URL, "http://zxcvbn.t35.com/test.php");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
res = curl_easy_perform(curl);
if(res)
{
printf("curl_easy_perform failed: %d\n", res);
}
curl_formfree(post);
}
else
printf("curl_easy_init failed\n");
return 0;
}
And I am getting the error:
curl_easy_perform failed: 7