I don't have much time these days to debug other people's code, so I will leave you the homework ...
But here are some hints :
- First, in the onFileUpload() callback, you need to follow the multiple calls behavior, so you need to have the upload.status checks for all UPLOAD_FILE_START/UPLOAD_FILE_WRITE/UPLOAD_FILE_END steps, this means having the SPIFFS.open/write/close accordingly in each steps.
- Due to multiple calls mentioned above, your SPIFFS file descriptor (File f) needs to be either global or static, since it need to be persistent across each onFileUpload() calls.
- For the compiles error, change the f.print() with f.write(), especially that it need to be done with argument upload.currentSize for each blocks been copied during each UPLOAD_FILE_WRITE calls, considering that you can have multiple calls, buffer limited to 2048 bytes by calls.
Hoping this help,