Update:
As discussed in Jacob's reply below, limiting or correcting the behaviour of FileReference.save isn't possible. Can anyone suggest an alternative (server is Apache/PHP) that matches all of my criteria from this post and avoids the pitfalls I discussed with Jacob?
End edit
I'm saving an image from my AS3 app using FileReference.save(). This is the code, which works fine:
var encoder:JPGEncoder = new JPGEncoder(80);
var byteData = encoder.encode(myBMD); //bitmap data object created earlier
var file:FileReference = new FileReference();
file.save(byteData, "myImage.jpg");
This opens up the save file dialog as expected. I'm using this rather than sending the byteData to PHP because I want the user to have a familiar dialog box that lets them set their own file name.
The problem comes when users have their operating system configured to display file extensions, like I do. This means that in the save dialog the file name contains the extension as seen in the image below, and so it is very easy for the user to delete that extension when they rename the file. Because the default file type for this box is 'All files', if the extension is deleted the file is saved with no type.
I don't know of any way to force a file type on the save dialog (if there is one that would be my preferred route) so failing that can anyone suggest a safe way for me to do this that still allows the user to set the file name themselves using a standard dialog for their OS?
I did try putting in a call to FileReference.browse() before the save() as shown in this tutorial, but that throws an error because you can only perform one FileReference call at a time.