cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Perhaps its not post

From: Paul Thompson <prtsoft_at_gmail.com>
Date: Fri, 14 Jul 2006 12:31:28 -0400

I looked a the header that curl sent and the once the the onlien from sent
the curl didn't have the ENCTYPE="multipart/form-data", while the online one
did.

On 7/14/06, man_at_tfhs.net <man_at_tfhs.net> wrote:
>
> the error you are getting is likely misleading. there are multiple
> 'content type' settings in a multi-part post, one in the http headers, and
> one for each 'file' that gets uploaded. curl will set the first correctly,
> but you must set the others yourself.
>
> dont set the content type of the mp3 file to multi-part. i bet thats your
> issue.
>
> allan
>
> On Fri, Jul 14, 2006, Paul Thompson <prtsoft_at_gmail.com> said:
>
> > 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! :)
> >
>
> --
> m. allan noah
> IT Director, TfHS.net
> ph# (804) 355-5489
> tf# (866) 724-9722
> fx# (804) 355-0477
>
>
>

-- 
P.S: this is what the alphabet would look like with Q and R removed! :)
Received on 2006-07-14