Hi,
just looking for a little piece of C code (cgi script) that can handle a simple file upload to a server from a browser. Or does anyone know of any general library for such tasks,
Thanks in advance,
Brett :)
Printable View
Hi,
just looking for a little piece of C code (cgi script) that can handle a simple file upload to a server from a browser. Or does anyone know of any general library for such tasks,
Thanks in advance,
Brett :)
cgi and C code are different in syntax and their operations, try looking at some server side langs like cgi and php.
You can also do it directly from html, though i wouldnt recommend this - also if its not your own server you may find security restrictions stop you from such upload scripts
HTML does have a file upload control
When the submit button is pressed, the file is POST'ed to the server. It is recieved and then must be decoded as it is recieved with the MIME type "multipart/form-data". Do a search to find more on this encoding. I do it in Java, and the decoding class has already been written (borrowed :) )Code:<FORM ACTION="http://myserver.com/cgi"
ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="MyFile">
</FORM>
The problems you have;
1. Getting a decent decoding program to multitask and actually work on your server
2. As Iain said - Getting your server to allow uploads. Many hosts dont like it :)
3. Security - be very carefull what files you allow up and where you save them. It would be a shame for you to get this up and running only for some kiddie to upload a script and then run it :p