hi there,
wxHTTP is relatively uncommented in the docs. is there a way to post data to a php script easily?
kind regards juergen
posting data with wxHTTP Topic is solved
-
- Earned some good credits
- Posts: 122
- Joined: Fri Jun 10, 2005 8:34 am
- Location: Austria
- Contact:
posting data with wxHTTP
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GB/CS/CM/IT !d++ s+:-- a-- C++++$ UBL*++++$ P--- L++++$ !E-- !W+++$? !N-- !o K--? w++()$ !O M$ !V !PS? !PE? !Y? !PGP !t !5 !X R+++ tv++ !b? DI D++ G e+++ h++ r++ y+
------END GEEK CODE BLOCK------
Version: 3.1
GB/CS/CM/IT !d++ s+:-- a-- C++++$ UBL*++++$ P--- L++++$ !E-- !W+++$? !N-- !o K--? w++()$ !O M$ !V !PS? !PE? !Y? !PGP !t !5 !X R+++ tv++ !b? DI D++ G e+++ h++ r++ y+
------END GEEK CODE BLOCK------
Re: posting data with wxHTTP
Yes, but not with wxHTTP. CURL is very useful, full featured, easy and works well with wxWidgets. There is also a wx wrapper called wxCurl, but i can't testify to it's usefulness as i just use CURL directly.FireMail wrote:wxHTTP is relatively uncommented in the docs. is there a way to post data to a php script easily?
-Max
-
- I live to help wx-kind
- Posts: 194
- Joined: Mon Aug 30, 2004 1:26 pm
- Location: PA, USA
- Contact:
I have a wxHTTPPost class
https://anon:@scm.wilcoxd.com:8081/svn/ ... xHTTPPost/
Also, wxCurl is pretty good - and easier than using curl directly (as I've done both approaches)
Hope this helps
https://anon:@scm.wilcoxd.com:8081/svn/ ... xHTTPPost/
Also, wxCurl is pretty good - and easier than using curl directly (as I've done both approaches)
Hope this helps
-
- Earned some good credits
- Posts: 122
- Joined: Fri Jun 10, 2005 8:34 am
- Location: Austria
- Contact:
i tried it now with curl directly - its really easy to use, but it looks for me like i made an error. maybe you find quickly whats wrong here.
i try to upload an image with curl - by using a php file.
curl code:
the php code:
data is uploaded and everything works fine, except that the uploaded data is not the same as the original one - the image gets corrupted. maybe you have an idea. kind regards
i try to upload an image with curl - by using a php file.
curl code:
Code: Select all
CURL *easyhandle = curl_easy_init();
curl_easy_setopt( easyhandle, CURLOPT_URL, "http://url.com/upload.php" );
char *error = new char[CURL_ERROR_SIZE];
curl_easy_setopt(easyhandle, CURLOPT_ERRORBUFFER, error);
curl_httppost *post = NULL;
curl_httppost *last = NULL;
curl_slist *headers = NULL;
headers = curl_slist_append( headers, "Content-Type: image/png");
curl_formadd( &post, &last, CURLFORM_COPYNAME, "user", CURLFORM_COPYCONTENTS, "990", CURLFORM_END );
curl_formadd( &post, &last, CURLFORM_COPYNAME, "pic", CURLFORM_FILECONTENT, "unknown.png", CURLFORM_CONTENTHEADER, headers, CURLFORM_END);
curl_easy_setopt( easyhandle, CURLOPT_HTTPPOST, post );
curl_easy_perform( easyhandle );
curl_formfree( post );
curl_slist_free_all( headers );
Code: Select all
$fp = fopen( $_POST['user'].".png", "wb+" );
fwrite( $fp, $_POST['avatare'] );
fclose($fp);
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GB/CS/CM/IT !d++ s+:-- a-- C++++$ UBL*++++$ P--- L++++$ !E-- !W+++$? !N-- !o K--? w++()$ !O M$ !V !PS? !PE? !Y? !PGP !t !5 !X R+++ tv++ !b? DI D++ G e+++ h++ r++ y+
------END GEEK CODE BLOCK------
Version: 3.1
GB/CS/CM/IT !d++ s+:-- a-- C++++$ UBL*++++$ P--- L++++$ !E-- !W+++$? !N-- !o K--? w++()$ !O M$ !V !PS? !PE? !Y? !PGP !t !5 !X R+++ tv++ !b? DI D++ G e+++ h++ r++ y+
------END GEEK CODE BLOCK------