1

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 '17 at 23:21
  • You can download file stream without writing to a temporary location. – Venkat Konjeti Jun 6 '17 at 23:21
  • 1
    see this example. I haven`t try but you can create sample ourcodeworld.com/articles/read/189/… – Venkat Konjeti Jun 6 '17 at 23:22
  • @Mike I just want them to be able to pull a text file to their downloads folder. – bgmCoder Jun 7 '17 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 '17 at 15:17
0

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
sessionStorage.removeItem('key');

// Remove all saved data from sessionStorage
sessionStorage.clear();

https://developer.mozilla.org/en/docs/Web/API/Window/sessionStorage

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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