Re: post image to webhoster - upload file with http
- From: "Gernot Frisch" <Me@xxxxxxxxxxx>
- Date: Tue, 9 Jan 2007 09:31:37 +0100
this question might be off topic, but anyway.
I want to upload an image to imageshack in C++. I have a function,
where I can specify a url, post data and header.
Do I need to include the image data (mime boundary thingy) in the
header?
Or uhm.. where do I put the image data when uploading?
Got it working. FYI:
// Make POST data for file upload
String boundary, sHeader, sPostData, sFileContent;
boundary="--UPLOAD--BOUNDARY--123j123498sadfj32--UPLOAD-BOUNDARY--";
sHeader = "Content-Type: multipart/form-data,
boundary="+boundary+"\r\n";
sFileContent.ReadBinary(file_name);
#define ADDVAR(s, n, v) \
s = s + "--"+boundary \
+ "\r\nContent-Disposition: form-data; name=\""\
+ String(n)+ "\"\r\n\r\n"\
+ String(v)+"\r\n";
ADDVAR(sPostData, "MAX_FILE_SIZE", "1048576");
ADDVAR(sPostData, "Submit1", "host it!");
// Post the file
sPostData +=
"--"+boundary+"\r\n"
"Content-Disposition: form-data;"
" name=\"fileupload\";"
" filename=\""+filename+"\"\r\n"
"Content-Transfer-Encoding: binary\r\n"
"Content-Type: application/octet-stream\r\n\r\n"
+ sFileContent + "\r\n";
sPostData += "--"+boundary+"--";
CAmHttpSocket http;
char *s = http.GetPage(
_T("http://mysite/index.php"),
true,
sPostData, sPostData.GetLength(),
sHeader
);
.
- References:
- post image to webhoster - upload file with http
- From: Gernot Frisch
- post image to webhoster - upload file with http
- Prev by Date: Image issues
- Next by Date: Re: FUSK!
- Previous by thread: post image to webhoster - upload file with http
- Next by thread: Newbie Help. PHP4 to PHP5: problem listing $_GET values.
- Index(es):
Relevant Pages
|