/* it should be noted that for the HTTPPOST_FILENAME and
HTTPPOST_CALLBACK cases the ->showfilename struct member is always
assigned at this point */
- char *filebasename=
- (!post->showfilename)?strippath(post->contents):NULL;
-
- result = AddFormDataf(&form, &size,
- "; filename=\"%s\"",
- (post->showfilename?post->showfilename:
- filebasename));
- if(filebasename)
- free(filebasename);
+ if(post->showfilename || (post->flags & HTTPPOST_FILENAME)) {
+ char *filebasename=
+ (!post->showfilename)?strippath(post->contents):NULL;
+
+ result = AddFormDataf(&form, &size,
+ "; filename=\"%s\"",
+ (post->showfilename?post->showfilename:
+ filebasename));
+ if(filebasename)
+ free(filebasename);
+ }
if(result)
break;
s/boundary=----------------------------[a-z0-9]*/boundary=----------------------------/
</strippart>
# Note that the stripping above removes 12 bytes from every occurance of the
-# boundary string and since 4 of them are in the body contents, we see
-# 415 - (4*12) here == 367 bytes.
+# boundary string and since 5 of them are in the body contents, we see
+# (5*12) == 60 bytes less
<protocol>
POST /554 HTTP/1.1\r
Host: %HOSTIP:%HTTPPORT\r
Accept: */*\r
-Content-Length: 415\r
+Content-Length: 561\r
Expect: 100-continue\r
Content-Type: multipart/form-data; boundary=----------------------------\r
\r
\r
this is what we post to the silly web server
\r
+------------------------------\r
+Content-Disposition: form-data; name="callbackdata"\r
+\r
+this is what we post to the silly web server
+\r
------------------------------\r
Content-Disposition: form-data; name="filename"\r
\r
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct WriteThis pooh;
+ struct WriteThis pooh2;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
if(formrc)
printf("curl_formadd(1) = %d\n", (int)formrc);
+ /* Now add the same data with another name and make it not look like
+ a file upload but still using the callback */
+
+ pooh2.readptr = data;
+ pooh2.sizeleft = strlen(data);
+
+ /* Fill in the file upload field */
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "callbackdata",
+ CURLFORM_STREAM, &pooh2,
+ CURLFORM_CONTENTSLENGTH, pooh2.sizeleft,
+ CURLFORM_END);
+
+ if(formrc)
+ printf("curl_formadd(1) = %d\n", (int)formrc);
+
/* Fill in the filename field */
formrc = curl_formadd(&formpost,
&lastptr,