Some file types, such as media files, have a metadata embedded in their format, so it really depends on what kind of file you're talking about.
However, you're better off tracking this in your system. For example, in our application we generate filenames that we use on disk from a UUID and then just track the original file name in our database.
That allows us to show the original filename to users and even push the file back to the user with the original filename, but we make sure that on disk the filename won't conflict with any file system limitations and will not conflict with other file resources being uploaded.