|
NetBurner 3.5.8
PDF Version |
Example Path: examples/SSL/HtmlFilePost
This example uploads a file to the NetBurner device over an encrypted HTTPS connection. The browser sends the file as a multipart/form-data POST, the application reads the first 10 KB into a buffer, and the contents are echoed back on a result page – either as text or as a hex + ASCII dump.
It is the secure counterpart of the standard examples/Web/FilePost example – the only functional difference is that the web server is started with StartHttps() and the device serves the page with an embedded TLS certificate and private key.
UserMain() initializes the network stack and starts the HTTPS server with StartHttps().index.html over HTTPS and the user picks a file (and, optionally, ticks "Show as binary").filepost.html, which is handled by the PostCallBack() callback registered in formcode.cpp.eFile event the file bytes are buffered; during the eVariable event the binary-display checkbox is recorded. At eEndOfPost the handler issues a RedirectResponse() to the static result.html.result.html contains a <!--CPPCALL ShowUploadedFile --> tag. As the page is served, ShowUploadedFile() writes just the file contents into the page – keeping the page markup out of the C++ source.ShowUploadedFile CPPCALL handler.&, <, >, and "; carriage returns become <BR>.FILE_BUFFER_SIZE; larger files are truncated. Increase the buffer for bigger uploads.EnableSystemDiagnostics() is enabled for development and would typically be removed for production.examples/Web/FilePost – the same example without SSL/TLS.