2

I wanted to upload a jpeg image file on the server.I have a GoAhead web server which supports only cgi c program as a serverside handeling.

Can any one know how to handle http posted image file in program witten in cgi in c language?

Ahesanali Suthar
  • 341
  • 3
  • 23

2 Answers2

0

The GoAhead web server has a file upload filter for this purpose. The upload filter receives the uploaded file and saves it to disk. It then sets some request variables describing the upload. Those variables are accessible via CGI or via action functions or JST templates.

There is an example in test.c. Search for uploadTest().

See: https://github.com/embedthis/goahead/blob/master/test/test.c

SenseDeep
  • 3,026
  • 3
  • 17
  • 19
-1

To get POST data just read stdin. Environment variable CONTENT_LENGTH tells you how much to expect but of course you need to make your code robust against whatever a potentially malicious user can throw at you.

stark
  • 12,615
  • 3
  • 33
  • 50
  • 1
    Yes i can get POSTED data using CONTENT_LENGTH but while uploading using multi-part browser adds multipart boundry and some headers.Do you know how to remove that boundry? – Ahesanali Suthar Jun 26 '12 at 05:17