|
NetBurner 3.5.8
PDF Version |
Example Path: examples/FTP/FTPD_ExposeHtml
This application creates a read-only FTP server that exposes HTML files from an embedded system as a browsable file system. It's designed for embedded systems using a network stack and provides both web server functionality and FTP access to HTML content.
The home page also lists every exposed file as clickable HTTP links (generated on the device from the same directory tree the FTP server reports), so the files can be browsed in any modern browser. This matters because browsers removed built-in ftp:// support around 2021 - the HTTP list and an FTP client (e.g. FileZilla) can be opened side by side to compare the two views.
\nburn\examples\EFFS folderThe application initializes a network stack and starts two main services:
The application builds a virtual file system from HTML files that are compiled into the application:
UserMain() - Main application entry point, initializes serviceswebListFiles() - Renders the exposed file tree as a browsable list of HTTP links on the web pageBuildDirTree() - Constructs file system tree from HTML dataGetDir() - Locates directories in the virtual file systemgetDirString() - Formats file/directory information for FTP clientsFTPD_ListFile() - Lists files in a directoryFTPD_ListSubDirectories() - Lists subdirectories FTPD_DirectoryExists() - Checks if directory existsFTPD_SendFileToClient() - Transfers files to FTP clientsFTPD_FileExists() - Verifies file existenceFTPDSessionStart() - Handles FTP client connectionsFTPDSessionEnd() - Manages session cleanupftp://[device-ip] with an FTP client such as FileZilla. The same files appear, so the HTTP and FTP views can be compared directly.ftp:// links no longer open in Chrome, Firefox, or Edge (support removed ~2021). Use the HTTP list or an FTP client instead.Starting in 2020, some web browsers have begun blocking direct FTP access. In such cases:
The current implementation accepts all FTP connections without password verification. For production use, implement proper authentication in FTPDSessionStart().
init.h)ftpd.h)htmlfiles.h)netinterface.h)The following FTP operations are supported:
These FTP operations always return failure:
This is an advanced application requiring knowledge of:
The complexity primarily involves managing virtual directory structures and handling FTP client requests for file navigation and display.
The application provides diagnostic information via serial port: