curl-library
libcurl file upload as a form field of a file made using tmpfile()
Date: Mon, 19 Apr 2010 03:03:29 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
iQEcBAEBAgAGBQJLzCp3AAoJELtWTuA59M89iAcH/3JoiCqej0XbmugBWyayZKEr
y0/lIUEygL9EOhymaTSIbTZSPjM3bxvIwxhnp8x8E6PRUyJMBWprVDWdQRdr9/jl
4XhRxwOHlfEbZqAK/LPTc6USgO5PzhRBgC7RzoceGC0LAGbOYcr9OD2+ibhD9X9T
Ln0YGWXwl3YylDizveqcmemg3yWjG5Fl8NV17MQfRIH+TPs0FCgaLmiwjMhL68U4
RFIK111AvoKHIEzkMw/9paFVC5Kok/Ph17dzmrmZrdp77GJi/zKGikhvSOhf1Gk3
rhjIAkiBZiS6JvWY7Og3702kp0Q9apjUUfkbDuCvN4tt0hcL+4Mhoi8EHu2LwJ8=
=ecSa
-----END PGP SIGNATURE-----
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-19