First, what do you mean by "file on remote server" ? How is this file accessed?
If you're talking about a URL which prompts your browser to open or save a file, you could use [man]get_headers/man and parse out the 'Content-Disposition' header to see if it contains a filename (and, if not, probably default to assuming that the last component of the URL path component is to be used).