How to upload image file using cgi program written in c language?

北慕城南 提交于 2019-12-11 04:55:20

问题


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?


回答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.




回答2:


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



来源:https://stackoverflow.com/questions/11166832/how-to-upload-image-file-using-cgi-program-written-in-c-language

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!