简体   繁体   English

如何使用用C语言编写的CGI程序上传图像文件?

[英]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.

相关问题 如何调试用C编写并在Apache2中运行的cgi程序? - How to debug cgi program written in C and running in Apache2? 如何通过用C编写的cgi-bin程序检索表单“ POST”数据 - How to retrieve form “POST” data via cgi-bin program written in C 如何将C程序转换为CGI? - how to convert c program to cgi? 使用CGI C程序将文件保存到www目录 - Saving file with CGI C program to www directory 在Web服务器端使用用C编写的CGI脚本的缺点? - Disadvantages of using CGI scripts written in C for web server-side? C CGI程序:如何动态打印? - C CGI Program: how to print dynamically? 在由C语言编写的CLI程序中嵌入由Flex和Bison生成的yyparse() - Embed yyparse(), generated by Flex and Bison, on CLI program written in C language 如何使用 MinGW GCC 在 Windows 下将用 D 编写的库链接到用 C 编写的程序? - How to link a lib written in D to use it with a program written in C, under Windows, using MinGW GCC? 在终端中执行用 C 编写的文件复制程序 - Executing a File Copying program written in C in terminal 如何使用C语言编写的CGI应用程序中的系统命令在Web浏览器(Apache服务器)上执行批处理脚本 - How to execute a batch script using system command in a CGI application written in C, executed through web browser (Apache Server)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM