cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curlpp mailing list Archives

[cURLpp] C#/C++ - how to upload a file using post?

From: Hristo Mitev <duronrulez_at_gmail.com>
Date: Sat, 3 Feb 2007 13:04:00 +0200

I have a basic form

<form name="ImageUploadForm1" method="post" action="URLTOPOSTTO"
id="ImageUploadForm1" enctype="multipart/form-data">
<input name="ImageToUpload" type="file" id="ImageToUpload" size="24" />
<input type="submit" name="ButtonUpload" value="Upload" id="ButtonUpload" />

I want to post the file using curl. So far i have succeeded in uploading an
empty file ... dunno why. Here is my code (in C# but i assume in c++ wont be
very different):

            Easy easy = new Easy();
            easy.SetOpt(CURLoption.CURLOPT_URL, "URLTOPOSTTO");
            easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, 1);
            easy.SetOpt(CURLoption.CURLOPT_POST, 1);
            easy.SetOpt(CURLoption.CURLOPT_COOKIEJAR, "cookies");
            easy.SetOpt(CURLoption.CURLOPT_COOKIEFILE, "cookies");
            easy.SetOpt(CURLoption.CURLOPT_USERAGENT, "Mozilla/5.0 (Windows;
U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6");
            easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, "ImageToUpload=" + "
BASEBALL.MPG&ButtonUpload=Upload");
            easy.Perform();
            easy.Cleanup();

This code sends the proper headers (i think) but the file i upload is empty.
I assume i am missing a point ... Help! Probably need to load the file
content in the postfields???

_______________________________________________
cURLpp mailing list
cURLpp_at_rrette.com
http://www.rrette.com/mailman/listinfo/curlpp
Received on 2007-02-03

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET