cURL / Mailing Lists / curl-library / Single Mail

curl-library

Uploading a file created using tmpfile()

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

Hi,

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" />
</form>

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);
    rewind(fl);
    long arglen = strlen(argname)+1;
    char *ret = (char*) malloc(len+arglen);
    ret[0]='F';
    ret[1]='1';
    ret[2]='=';
    fread(ret+arglen,1, len, fl);
    fclose(fl);
    return ret;
}

Can someone help me out

-- Ankur

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-19