[英]How to upload image file using cgi program written in c language?
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. 我想在服务器上上传一个jpeg图像文件。我有一个GoAhead网络服务器,该服务器仅支持cgi c程序作为服务器端处理。
Can any one know how to handle http posted image file in program witten in cgi in c language? 谁能用c语言在cgi中用witten程序处理http发布的图像文件吗?
To get POST data just read stdin. 要获取POST数据,只需阅读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. 环境变量CONTENT_LENGTH告诉您期望值,但您当然需要使代码更强大,以应对潜在的恶意用户可能向您扔的任何东西。
The GoAhead web server has a file upload filter for this purpose. GoAhead Web服务器具有用于此目的的文件上传过滤器。 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. 这些变量可以通过CGI或动作函数或JST模板进行访问。
There is an example in test.c. test.c中有一个示例。 Search for uploadTest(). 搜索uploadTest()。
See: https://github.com/embedthis/goahead/blob/master/test/test.c 参见: https : //github.com/embedthis/goahead/blob/master/test/test.c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.