Panel's FileInput widget

Hello all,

Similar issues have already been discussed here and there but I can’t get any of the hints working in my case. I’m trying to retrieve the path of a file selected using panel’s (0.7.0) FileInput widget:

file_input = pn.widgets.FileInput(name='Upload file', accept='.H')
@pn.depends(file_input.param.value, watch=True)
def process_file(file_input):
    if file_input.value == '' or file_input.value == None:
        return 'First select a valid SEP file.'
        return SepInfoWrapper(file_input2), 'value')
pn.Column(file_input, process_file(file_input)).servable()

When the file has been selected, file_input.value sends back the good value however file_input.filename sends back None. Impossible then to have my SepInfoWrapper function, which relies on a file path, working…

Is it a bug or is it just me not using it right?

We can have a look at why it isn’t providing the filename but there is no way of providing the whole path of the file as that would break the browser security model. We do want to add a file browser widget for the remote file system (i.e. the system the app is running on) which will be able to provide filepaths.

It would indeed be very helpful to have a widget capable of providing filepaths. At least for my use, it would allow me to interface our in-house existing codes with Panel without having to modify their behaviour. In the meanwhile, if I could have access to the filename only, it would already be an advantage. I would then “cheat” and “oblige” the final user to have the file in a given, particular folder.

1 Like