Error message when running via Voila but the notebook is working well at Jupyter

Yes, exactly. Voila runs all the code first to initiate things. You have to build in methods to deal with that and then how to handle the next steps. It seems you are just using some basic code that makes the buttons themselves and not building in the handling. See the thread here from this point forward to give you some pointers how to deal with the upload.