You need to design the web page so that it presents a control that the user can use to request the save. For example you could include a form with a submit button, or just use a hyperlink.
You need to design your web server so that it recognises the HTTP request corresponding to the save request. The most obvious way to do that is to have the submitted URL path specify the save request.
Your sketch needs to determine the file name to save to using whatever algorithm you want. One algorithm would be to generate a name which included a sequence number and just keep incrementing the sequence number until you find a name for which there is no existing file.