Customizing example 4 - User-Based Session Data on the Server

I am trying to customize example 4 of this link for my scenario:

In my case, I need to save the uploaded excel file’s content into a dataframe and use it for other button events.

So the what I want:

  1. When a user drag and drop or upload a file, I display it immediately. User can upload files any number of times and the content will be updated with new file’s content.
  2. After displaying the content, I generate a dynamic button that will be clicked by the user to process the data.

Unfortunately, I have not stored any data anywhere yet, but displayed it only.

I tried a set of way to store the displayed data frame.

Way 1: approach is using hidden div. But, how can I store to hidden dive and display the data at the same time?

Way2: I tried the example 4 to store the data in a session. But, I was wondering, in that case, if the user upload a new file, how can I update the data in the session as it is cached and will not run again!