title: Cannot read jpeg binary data, buffer only has 4 bytes of data
body: <p>I am trying to read the JPEG file and store it in a buffer in C as part of the header of HTTP POST request, then use HTTP POST to upload to the server. But seems that it only reads the first 4 bytes of image data because on the server side I only get the first 4 hex characters of the image. What is wrong with my code? The OS is LINUX.</p>
  
  <p>I realize that on the fifth HEX of the IMAGE, its 0x00, which i think C interprets it as the terminator, or it just thinks the file stops right here... How to avoid this issue?</p>
  
  <pre><code>unsigned long fileLen;
  char *buffer;
  
  if ((fp = fopen(filename, "rb")) == NULL){
      printf("File could not be opened\n");
      exit(1);
  }else{
       fseek(fp, 0, SEEK_END);
       fileLen=ftell(fp);
       fseek(fp, 0, SEEK_SET);
       buffer=(char *)malloc(fileLen);
       fread(buffer, fileLen, 1, fp);
       fclose(fp);
  }
  </code></pre>