My project needs to create a text file for the user to download to a place of their choosing.

Wither should I save the temp file? There must be a place where the app has write permissions and the user has read permissions. The file only needs to remain long enough for the user's browser session.

(I tried to figure out how to do this with a filestream so I wouldn't need a temp location, but it doesn't seem possible.)

  • what are you trying to accomplish, or storing?
    – Mike
    Jun 6, 2017 at 23:21
  • You can download file stream without writing to a temporary location. Jun 6, 2017 at 23:21
  • 1
    see this example. I haven`t try but you can create sample ourcodeworld.com/articles/read/189/… Jun 6, 2017 at 23:22
  • @Mike I just want them to be able to pull a text file to their downloads folder.
    – bgmCoder
    Jun 7, 2017 at 0:22
  • @VenkatKonjeti say, that's a right nice javascript solution; I'm going to check it out - it doesn't answer my question, but it does solve my problem
    – bgmCoder
    Jun 7, 2017 at 15:17

1 Answer 1


The file only needs to remain long enough for the user's browser session.

Then use the Browsers SessionStorage

// Save data to sessionStorage
sessionStorage.setItem('key', 'value');

// Get saved data from sessionStorage
var data = sessionStorage.getItem('key');

// Remove saved data from sessionStorage

// Remove all saved data from sessionStorage


IE was the last Browser to implement this W3C standard.... in IE 8

  • I'm not sure I understand this. I need to save a file to a temporary location, not just a value. The reason is so that I can tell the browser to download the file. I need a temporary location.
    – bgmCoder
    Jun 7, 2017 at 13:32
  • 1
    Danny - thanks for the link; I'll consider a javascript solution - although it isn't the answer to my question.
    – bgmCoder
    Jun 7, 2017 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.