Hi,

Thank you for your answer.
So, I modified the code in the following way:
============================================================
int main()
{
int content_length;
char * s_content;
int i;
int c;

  printf("Content-type: text/html\n\n") ;
  printf("<HTML>\n") ;
  printf("<HEAD>\n") ;
  printf("<TITLE>Uploading result</TITLE>\n") ;
  printf("</HEAD>\n") ;
  printf("<BODY>\n") ;
  printf("<H1>Uploading result</H1>\n") ;

  content_length = atoi(getenv("CONTENT_LENGTH"));
  if(content_length == 0)
    return 0;

  printf("<BR>content_length: %d", content_length);
  printf("<BR>");       

  s_content = (char *) malloc(sizeof(char) * content_length);
  if(s_content == NULL)
    return 0;

  i = 0;
  c = getchar();
  while(!feof(stdin))
  {
    s_content[i] = c;
    c = getchar();
    i++;
  }

  if(ferror(stdin))
    printf("<BR>ERROR");
  else
    printf("<BR>NO ERROR");

  printf("<BR>At the end = %d", i);

  free(s_content);

  return 1;
}
============================================================

And I got the following output:
===========================
Uploading result
content_length: 32466
NO ERROR
At the end = 1441
===========================

What do you think?
Thanks,

--
Léa Massiot
-- 
View this message in context: 
http://www.nabble.com/c-cgi-script---html-file-uploading-tp19780000p19782826.html
Sent from the C-prog mailing list archive at Nabble.com.

Reply via email to