curl-users
HTTPPOST won't post
Date: Fri, 14 Jul 2006 11:52:36 -0400
i am working on a program that uploads MP3s to a server. The server needs
username, password, datafile and IDnumber.
However it appears that my code is not posting beacuse looking at a ethereal
dump all the is being sent to the server is the url, not the fields. Below
is my code:
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
struct curl_httppost* post = NULL;
struct curl_httppost* last = NULL;
struct curl_forms forms[1];
int main (int argc, char *argv) {
if(argc<=1)
{
printf("Sermon Audio Transfer Client - Sermon Upload \n");
printf("Usage: \n");
printf("satc-upload-mp3 username password filename sermonid\n");
return 0;
}
CURL *curl;
CURLcode res;
curl = curl_easy_init();
/* Add simple name/content section */
curl_formadd(&post, &last, CURLFORM_COPYNAME, "source",
CURLFORM_BUFFERPTR, argv[1], CURLFORM_END);
printf("Added source\n");
/* Add simple name/content/contenttype section */
curl_formadd(&post, &last, CURLFORM_COPYNAME, "password",
CURLFORM_BUFFERPTR, argv[2], CURLFORM_END);
printf("Added password\n");
/* Add name/ptrcontent section */
curl_formadd(&post, &last, CURLFORM_COPYNAME, "datafile",
CURLFORM_FILENAME, &argv[3], CURLFORM_CONTENTTYPE, "multipart/form-data",
CURLFORM_END);
printf("Added datafile\n");
/* Add name/ptrcontent/contenttype section */
curl_formadd(&post, &last, CURLFORM_COPYNAME, "SermonID",
CURLFORM_BUFFERPTR, argv[4], CURLFORM_END);
/* Set the form info */
printf("Added sermonid\n");
curl_easy_setopt(curl, CURLOPT_URL,
"pending.sermonaudio.com/winedit_audioadd-aspupload2.asp
");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
res = curl_easy_perform(curl);
printf("%d", res);
return 0;
}
Thank you!
-- P.S: this is what the alphabet would look like with Q and R removed! :)Received on 2006-07-14