What have you tried so far? This current code doesn't have any implementation for the save methods.
All you need to do is check if a filename has been provided and if it has, implement the save handling by writing the file using something like the FileOutputStream. If the filename is no good, prompt for the save as mechanism which simply provides a FileDialog to select a file to save to, captures that file information, and then attempts to save again. So separate the two parts, and chain the methods together to eliminate redundancy.
header('HTTP/1.1 420 Enhance Your Calm');