NetBurner 3.5.8
PDF Version
HTML File Post

Example Path: examples/SSL/HtmlFilePost

SSL/TLS File Post with Multipart Form

Overview

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.

Note
The bundled certificate is self-signed, so browsers display a warning unless you install the matching Certificate Authority. Choose the option to "continue anyway" to proceed.

How It Works

  1. UserMain() initializes the network stack and starts the HTTPS server with StartHttps().
  2. The browser loads index.html over HTTPS and the user picks a file (and, optionally, ticks "Show as binary").
  3. Submitting the form POSTs to filepost.html, which is handled by the PostCallBack() callback registered in formcode.cpp.
  4. During the 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.
  5. 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.

Files

  • main.cpp – entry point; initializes the network stack and starts the HTTPS server.
  • formcode.cpp – POST callback, file buffering, and the ShowUploadedFile CPPCALL handler.
  • index.html – upload form (file picker + binary-display checkbox).
  • result.html – result page shell; pulls in the file contents via CPPCALL.
  • style.css – self-contained stylesheet (plain CSS, no framework or CDN).
  • logo.png – header logo.
  • ServerCert.cpp / ServerKey.cpp – embedded TLS certificate and key.

Display Modes

  • Text mode – printable characters with HTML entity encoding for &, <, >, and "; carriage returns become <BR>.
  • Binary mode – a 16-byte-per-line hex dump with an ASCII column alongside.

Notes

  • Maximum file size is the 10,000-byte 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.

Related Examples

  • examples/Web/FilePost – the same example without SSL/TLS.