curl-library
Perhaps its not post
Date: Fri, 14 Jul 2006 12:10:01 -0400
The message I'm getting back from the server when I'm trying to upload an
MP3 is :
The following error occurred: Wrong Content-Type. Make sure you have
included the attribute ENCTYPE="multipart/form-data" in your form.
How do I set this?
Below is my code:
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
char url[] = "pending.sermonaudio.com/winedit_audioadd-aspupload2.asp";
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 */
/*I have specified that here.....did I do it wrong?*/
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;
}
I apologize if you get two emails, I wasn't subscribed the first time so I
don't know if it went through.
-- P.S: this is what the alphabet would look like with Q and R removed! :)Received on 2006-07-14