Losing extension when use FileReference download

后端 未结 4 772
醉酒成梦
醉酒成梦 2021-01-18 13:28

I need user download JPEG file from my app, however, when user change the file name the saved file will be downloaded without extension.

For Example: I am using File

4条回答
  •  误落风尘
    2021-01-18 14:25

    Had same problem. Used CONCAT to manually add extension. It does not appear in the dialog box when saving but DOES save as a text file with a .txt extension when viewed in Windows Explorer. Doesn't seem to work but actually does!

    var final_filename:String = filename.concat(".txt");
    

    //Create text to save from text field var newDataFile:TextField = new TextField(); newDataFile.text=myTextField.text; //create file reference to save file var file:FileReference = new FileReference(); file.save(newDataFile.text, final_filename);

提交回复
热议问题