Question

I am using FileReference.save to save a jpg to the user's computer. In Windows 7, I pass in 'test.jpg' as the file name to be saved but only 'test' appears in the file save dialogue ('test.jpg' appears as the file name in Windows Vista). So, unless the user manually adds the .jpg extension, Windows 7 does not know it is a jpeg file since it is just being saved as 'test'. I'd like to be able to pass the .jpg extension for the user but Windows 7 seems to be stripping the file extension from the file name that is passed to the file save dialogue.

fr = new FileReference();
fr.save(imgByteArray, 'test.jpg');
Was it helpful?

Solution

Alright so the issue is just that the OS is hiding the extensions from you. To fix it:

  1. Click Start Menu
  2. Click My Computer
  3. With my computer window having focus (click on it to be sure) hit the Alt key this will give you the older style menus.
  4. Click the Tools menu go down to Folder options...
  5. In the window that pops up click the second tab at the top called View.
  6. In the list of checkboxes at the bottom uncheck the Hide extension for known file types box.
  7. Hit OK
  8. Run your Flex program again

Alternative to steps 1 and 2 you can hit WinKey+E to get an explorer window.

Yay for technical writing 101.

When you do a save, browse, or download, action the dialog that's opened is OS dependent and so is treated with settings applied to the OS by the user. If you're in the context of AIR you can save directly without the dialogs using the FileStream class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top