Page 1 of 1

invalid operands of types 'const char*' and 'const char [8]' to binary 'operator+'

Posted: Mon Mar 16, 2020 8:50 pm
by zarar384
if (camClient.connect(postHost, postHttpPort))
{
uint8_t num = 1;
String base64image = "id=7292&num=" + num + "&image=" + (base64::encode(fb->buf, fb->len));

Serial.println("connection");
camClient.println("POST /test/image/post.php HTTP/1.0");
camClient.println("Host: cloud.****.com");
camClient.println("Accept: */*");
camClient.println("User-Agent: Mozilla/5.0");
camClient.println("Content-Length: " + base64image.length());
camClient.println("Content-Type: image/jpeg" );
camClient.println();

camClient.write(base64image.c_str());

//Serial.println(base64_encode_expected_len(fb->len) + 1);
//Serial.println(base64image.length());
camClient.stop();
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}


How can i fix this?
Error: invalid operands of types 'const char*' and 'const char [8]' to binary 'operator+'

Re: invalid operands of types 'const char*' and 'const char [8]' to binary 'operator+'

Posted: Mon Mar 16, 2020 10:35 pm
by pipi61
use (String) before contant?
...= (String)"id=7292&num="...

Re: invalid operands of types 'const char*' and 'const char [8]' to binary 'operator+'

Posted: Tue Mar 17, 2020 10:08 am
by zarar384

Code: Select all

uint8_t num = 12;
      String stringOne, stringTwo, stringThree, stringFour;
      String base64image = String();
      stringOne = String("id=7292&num=");
      stringThree = String("&image=");
      stringFour = String(base64::encode(fb->buf, fb->len));
      stringTwo = String(num);
      base64image = stringOne + stringTwo + stringThree + stringFour;
it is right??

Re: invalid operands of types 'const char*' and 'const char [8]' to binary 'operator+'

Posted: Wed Mar 18, 2020 10:10 am
by pipi61
try :)
or try
String base64image = (String) "id=7292&num=" + (String)num + (String) .............. ;