cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to POST file with filename?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 18 Oct 2009 02:24:54 +0200 (CEST)

On Thu, 15 Oct 2009, CP YEH wrote:

> I am trying to use libcurl to post a file and what I want to do is that I
> want to give filename and file content to the server so the server can save
> file according to the name I give. For instance, if I say
> "location=abc.txt&data=abc", the server will create abc.txt file and write
> abc to the abc.txt file.

That's an unusual way to do HTTP "upload". Most often people use multipart
formpost, or plain PUT.

> I can do the above fairly easily by following examples but what I
> really want to do is that I want to mmap file and simple pass it as an
> argument to libcurl.
> I am just not sure how I can pass mmap file together with "location=abc.txt"

You can't do it that way. You either pass a single argument to
CURLOPT_POSTFIELDS, or you solve it another way. Possibly by setting your own
read callback.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-10-18