cURL / Mailing Lists / curl-library / Single Mail


Re: How to POST file with filename?

From: Daniel Stenberg <>
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.

List admin:
Received on 2009-10-18