c_shelswell Posted June 17, 2008 Share Posted June 17, 2008 Hi I need to start a file downloading using javascript. I had been using php's header but i'm using ajax to collect a users email and it doesn't appear to work anymore. So i was hoping after my page had been called succesfully i could use javascript to start the download? I've tried window.open() which works fine but the firefox pop up stopper blocks it first is there a way to get round this? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/110603-initiate-a-file-download-using-javascript/ Share on other sites More sharing options...
ober Posted June 17, 2008 Share Posted June 17, 2008 You can't. You must load another window to push the download to the user. Your best bet is to either open a DIV that has a link to the file that the user can right click and download or use a PHP redirect to a new page. Keep in mind that JS can't call to the server to get the file, so you can't really expect it to be able to offer the file up. Quote Link to comment https://forums.phpfreaks.com/topic/110603-initiate-a-file-download-using-javascript/#findComment-567429 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.