why my image doesn't encode to base64 completly?

hi my image doesn't encode to base64 completly.but counter work correctly and it encoded just until counter=58 instead of counter=126. but counter count.and from 58 until end don't encoded.
i try another image it do until 53...i dont know what is my problem...please help me.thanks

{ enc = SD.open("ESP/enc.txt", FILE_WRITE);
  myFile = SD.open("ESP/16.jpg", FILE_READ);
  int sizeOfMyFile = myFile.size();
  Serial.println(sizeOfMyFile);
  int quotient = sizeOfMyFile / 3;
  Serial.println(quotient);
  if (myFile)
  {
    if (enc) {
      Serial.println("The File is Opened, And Please Show Data On Serial Port");

      // read from the file until there's nothing else in it:
      while (myFile.available())
      {
        if (quotient >= counter)
        { int lim=3;
          String data;
          byte input[lim];
          for (int i = 0; i < lim; i++)
          {
            input[i] = myFile.read();
            buffere += input[i];
          }
          int inputLen = sizeof(buffere);
          int encodedLen = base64_enc_len(inputLen);
          char encoded[encodedLen];
          base64_encode(encoded, input, inputLen);
          char sub[5];
          strncpy(sub, encoded, 4);
          sub[4] = '\0';
          // Serial.println(sub);
          data = sub;
          Serial.println(data);
          Serial.println("dakhele halghe quotient>counter");
        //  outFuncenc = forfuncencod(limit);
          enc.print(data);
          Serial.println("khoroojie tabe...");
          Serial.println(outFuncenc);

          counter++;
          Serial.println(counter);
        }

        if (quotient < counter)
        {
          if (sizeOfMyFile % 3 == 1) {
            Serial.println("dakhele halghe quotient<counter va limit=1");
            limit = 1;
            // forfuncencod(limit, connectionId,myFile);
         //   outFuncenc = forfuncencod(limit);
         //   outFuncenc += '=';
         //   outFuncenc += '=';
         //   enc.print(outFuncenc);
            //  espsend(outFuncenc, connectionId);

          }
          if (sizeOfMyFile % 3 == 2) {
            Serial.println("dakhele halghe quotient<counter va limit=2");
            limit = 2;
            //  forfuncencod(limit,connectionId,myFile);
         //   outFuncenc = forfuncencod(limit);
         //   outFuncenc += '=';
         //   enc.print(outFuncenc);
            //     espsend(outFuncenc, connectionId);

          }
        }
      }
    }

    enc.close();
    myFile.close();
    //   im = "\"alt=\"Red dot\" /></div>";
    //   espsend(im, connectionId);
    Serial.println("finish");
  }

What, for example, is buffere ?
You have to post the entire code otherwise it is more difficult to help.
You are using an ESP8266 ?

6v6gt:
What, for example, is buffere ?
You have to post the entire code otherwise it is more difficult to help.
You are using an ESP8266 ?

buffere is String and esp8266 are comment...
i want to send data with esp at the next step...

buffere is String

That is the problem. Don't use String objects.

mavaraiehasti:
buffere is String

Then you should use the length() method to retrieve its length and not a construct like this:

int inputLen = sizeof(buffere);

I'm not sure what this will retrieve, but I guess it could be length in bytes of the object handle.

I'm not sure what this will retrieve, but I guess it could be length in bytes of the object handle.

No, it'll return the size of all the object's variables

AWOL:
No, it'll return the size of all the object's variables

This would appear at first glance to contradict that statement . . .

void setup() {
  Serial.begin( 9600 ) ;

  String buf ;
  
  buf = "123456789" ;
  Serial.println( buf ) ;               // prints  123456789
  Serial.println( buf.length() ) ;      // prints 9
  Serial.println( sizeof( buf ) ) ;     // prints 6 !!

  buf = "1234" ;

  Serial.println( buf ) ;               // prints  1234
  Serial.println( buf.length() ) ;      // prints 4
  Serial.println( sizeof( buf ) ) ;     // prints 6  !!
}

void loop() {}


Output:
==================
123456789
9
6
1234
4
6
==================

I see no contradiction.
6 bytes is the value I recollect - a buffer pointer (2 bytes), a buffer length (another two bytes) and, I think, a string length (another two bytes).
The answer is easy for anyone with access to the source (I'm on my phone)

First glances are often deceptive.

Well, anyway, whatever.

One thing is clear. It is not the number of characters currently contained in the string and, as such, is useless in the context that the OP used it.