SJames Posted September 5, 2007 Share Posted September 5, 2007 I'm not sure whether I would use PHP for this or not, but what I am trying to do is automatically download a file when a window opens. I have a page with a link on it. When the link is clicked, a window pops up with a link to a file in it. I would like to be able to have that file start downloading as soon as the window opens. I'm not sure if this would be PHP or Javascript- any help would be nice, I can't seem to find this anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/ Share on other sites More sharing options...
cmgmyr Posted September 5, 2007 Share Posted September 5, 2007 take a look at header() you can use this to download a file. Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342111 Share on other sites More sharing options...
SJames Posted September 5, 2007 Author Share Posted September 5, 2007 I don't think that's what I'm looking for- I looked that up and tried it and it's more of a redirect. I'm talking about something more like the download sites where they bring you to a page and then you get the little "Website is trying to download file to your computer" thing. How to to try to download that file to your computer? Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342113 Share on other sites More sharing options...
rishiraj Posted September 5, 2007 Share Posted September 5, 2007 I think you can us this code header("location:download.zip"); make sure this code should be at the top of page and no echo or print before this sorry you replied while i was typing. I think you can do it by making a download page that print the downloading message and open the download fie in new window. Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342115 Share on other sites More sharing options...
cmgmyr Posted September 5, 2007 Share Posted September 5, 2007 ...correct you "redirect" to a file...which prompts you to download it Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342118 Share on other sites More sharing options...
SJames Posted September 5, 2007 Author Share Posted September 5, 2007 Well that sort of works, it prompts to download the file, but I cant put anything on the page and it only works with zip files. If someone tried to download a wmv it would just open the movie, not prompt to download... Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342121 Share on other sites More sharing options...
SJames Posted September 5, 2007 Author Share Posted September 5, 2007 How to I do the redirect thing? Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342125 Share on other sites More sharing options...
cmgmyr Posted September 5, 2007 Share Posted September 5, 2007 Check out http://www.expertsrt.com/tutorials/Matt/HTTP_headers.html and go to close to the bottom of the page, you will see a "Common MIME types" table on the right that you can use to change the file types. Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342129 Share on other sites More sharing options...
trq Posted September 5, 2007 Share Posted September 5, 2007 Check the FAQ/Code snippet... board. there is an example of what you want. Quote Link to comment https://forums.phpfreaks.com/topic/68061-auto-download/#findComment-342140 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.