Archived

This topic is now archived and is closed to further replies.

31337

CGI and Uploading Files with C++

Recommended Posts

31337    100
I''m trying to write a CGI script that will take a browse button + text field and upload the indicated file to the server into memory so I can parse it. I check the environment string QUERY_STRING (I think thats it) but it just gives me the filename and not the actual file. I''ve looked in the standard input put there''s nothing there I''ve even tried looking through cgic''s source code but documentation is very... unclear. All of the examples on the web are for perl which doesn''t help me for 2 reasons: 1) I don''t know perl. and 2) They all use some magical function that does it for them. So using C++, how do I actually get the file indicated by my form? Thanks in advance.

Share this post


Link to post
Share on other sites
pjcast    311
Your writing a client side CGI script? I''m not quite sure what you mean. Or do you mean you have a web page that has a file upload to a cgi script?

Make sure you are using the "post" method, enctype="multipart/form-data".
And something like <input type="file" name="filename" size="30" />

Anyway, I forget how to parse the post from stdin, but you just need to figure out how much data is sent, and read it into a buffer. You should be able to find a couple tutorials on multi part data, post, and file upload with c instead of perl.

Share this post


Link to post
Share on other sites
31337    100
I''ve tried checking stdin before and it was just garbage. I''m using get currently (versus post) and I suppose that changing that might switch things up a bit. I''m going to be at work in about an hour so I''ll play around with it a little bit more and try what you suggested.

I don''t understand how you interpreted me as saying that I''m writing a client cgi. The cgi is server side, just like all cgi''s.

Share this post


Link to post
Share on other sites