cURL / Mailing Lists / curl-library / Single Mail


Uploading a file created using tmpfile()

From: Ankur Chauhan <>
Date: Sun, 18 Apr 2010 21:46:44 -0700


I made a file using FILE* f = tmpfile();

now i have written some data into it and I want to upload this to a url using POST along with other fields
the form for the upload is as follows:
<form method="post" action="upload.jsp">
        <input type="text" name="videoID" />
        <input type="file" name="F1" />
        <input type="submit" name="submit" />

so i have written a function to read the binary content to a buffer and am stuck at how to transfer it to the server.

char* readFileBytes(const char *name, const char *argname){
    FILE *fl = fopen(name, "rb");
    if(fl == NULL)
        return NULL;
    fseek(fl, 0, SEEK_END);
    long len = ftell(fl);
    long arglen = strlen(argname)+1;
    char *ret = (char*) malloc(len+arglen);
    fread(ret+arglen,1, len, fl);
    return ret;

Can someone help me out

-- Ankur

List admin:
Received on 2010-04-19