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

zarar384
Posts: 6
Joined: Fri Mar 06, 2020 2:18 pm

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

Postby zarar384 » Mon Mar 16, 2020 8:50 pm

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+'

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

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

Postby pipi61 » Mon Mar 16, 2020 10:35 pm

use (String) before contant?
...= (String)"id=7292&num="...

zarar384
Posts: 6
Joined: Fri Mar 06, 2020 2:18 pm

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

Postby zarar384 » Tue Mar 17, 2020 10:08 am

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??

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

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

Postby pipi61 » Wed Mar 18, 2020 10:10 am

try :)
or try
String base64image = (String) "id=7292&num=" + (String)num + (String) .............. ;

Who is online

Users browsing this forum: Masoud123456 and 108 guests