Jagand Posted September 1, 2012 Share Posted September 1, 2012 Hi, I would like to dynamically generate and download file such as example.txt using JavaScript. Using FSO OpenTextFile Method is saving but not mentioning the saved location. I would like the user to be prompted with options such as 'Save As', Open etc. How do I do this? As always, Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/267900-dynamically-generate-and-download-filedocument-using-javascript/ Share on other sites More sharing options...
codefossa Posted September 2, 2012 Share Posted September 2, 2012 Use server-side scripting to change the header, and it will download. So you'll link to a PHP page rather than using pure javascript. Quote Link to comment https://forums.phpfreaks.com/topic/267900-dynamically-generate-and-download-filedocument-using-javascript/#findComment-1374593 Share on other sites More sharing options...
Jagand Posted September 2, 2012 Author Share Posted September 2, 2012 Thank you so much. Would you mind giving sample code snippet that can tell me how to write code that puts file on client system and never keeps them on server. Quote Link to comment https://forums.phpfreaks.com/topic/267900-dynamically-generate-and-download-filedocument-using-javascript/#findComment-1374623 Share on other sites More sharing options...
Christian F. Posted September 2, 2012 Share Posted September 2, 2012 That didn't make any sense, I'm afraid. If you want to send the users something from the server, then it has to be on the server in the first place. Same way you can't give someone a hundred dollars from your wallet, if you don't have a hundred dollars in it. Also, we're not here to write the code for you, but to help you with problems with the code you've written yourself. So if you want help, you will have to post the code you already have. Otherwise we can't do anything but guess, and most of us are too busy to spend time on doing something that's ultimately mostly a waste of time. If you want to make something server-side, then I recommend reading up on PHP and how it handles file uploads. If not, then see above. PS: I strongly recommend that you read this article. Quote Link to comment https://forums.phpfreaks.com/topic/267900-dynamically-generate-and-download-filedocument-using-javascript/#findComment-1374711 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.