[En-Nut-Discussion] File upload via Http

Vesa Jääskeläinen chaac at nic.fi
Thu Mar 31 14:57:33 CEST 2005


Ralf Spettel wrote:
> Hi, thx for your answers. My problem is not to send the file. I want to 
> know, how can I access the transmitted data.
> Is there a funktion in th eOS which support the HTTP-POST method an 
> delivers a pointer to the received data..
> 
>  Ralf

There is no built in support for this, but you could apply patch 
#1164563 from tracker and then do something like this:

     if (req->req_method == METHOD_POST)
     {
         char *line;
         int pos;
         int ch;

	// Limit data to maximum of 4096 characters
         if (req->req_length > 4096) req->req_length = 4096;

         if ((line = NutHeapAlloc(req->req_length+1)) != 0)
         {
             for (pos = 0; pos < req->req_length; pos++)
             {
                 ch = fgetc(stream);
                 if (ch == EOF) break;

                 line[pos] = ch;
             }

	    // process data here...

             NutHeapFree(line);
	}
     }

Thanks,
Vesa Jääskeläinen



More information about the En-Nut-Discussion mailing list