daydreamer Posted September 25, 2008 Share Posted September 25, 2008 how can i download a file using php, when the file link is like this: https://www.example.com/download/ It is just a text file, and when you go to the URL in your browser it gives you the option to either open it or download it. How can I download it using PHP and save it to my local hard drive? Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/ Share on other sites More sharing options...
GingerRobot Posted September 25, 2008 Share Posted September 25, 2008 Well, you can't make someone download something, can you? I mean, that'd be a pretty big security risk, no? All you can do is offer them the option to download a file or open/run it. If that's what you're after (wasn't sure, your question was a bit ambiguous) then google for php force download. You'll find plenty of information Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650671 Share on other sites More sharing options...
efficacious Posted September 25, 2008 Share Posted September 25, 2008 well you might be able to use the "file" function of php to make a copy of the file. That would be just the same.. pretty much http://us3.php.net/manual/en/function.file.php Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650674 Share on other sites More sharing options...
DarkWater Posted September 25, 2008 Share Posted September 25, 2008 well you might be able to use the "file" function of php to make a copy of the file. That would be just the same.. pretty much http://us3.php.net/manual/en/function.file.php That doesn't even relate to what he asked....Anyway, do you want a personal PHP script to download a file off a server, or do you want to offer a file for downloading? Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650675 Share on other sites More sharing options...
daydreamer Posted September 25, 2008 Author Share Posted September 25, 2008 lol sorry for not being specific. I have my server, and want to download a file from another www server(not mine). this is for personal uses. I do not want to offer a download to anyone! any questions just ask! -thanks. Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650679 Share on other sites More sharing options...
DarkWater Posted September 25, 2008 Share Posted September 25, 2008 file_get_contents() or cURL would be your best bet. Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650686 Share on other sites More sharing options...
daydreamer Posted September 25, 2008 Author Share Posted September 25, 2008 yeh i am trying curl at the moment, but the problem is that I do not have a direct download link. e.g the address is like: www.example.co.uk/download/ When i go to the page with my browser it offers me a download or open the file box. Seing as cURL is the "Client URL Library", I should be able to mimick my browser actions and download the file some how right? any suggestions? Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650697 Share on other sites More sharing options...
DarkWater Posted September 25, 2008 Share Posted September 25, 2008 Did you even try downloading it with cURL? It should work. Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650698 Share on other sites More sharing options...
daydreamer Posted September 25, 2008 Author Share Posted September 25, 2008 yeh i have tried downloading it. I just get html code of the page, and not the actual file i need. Link to comment https://forums.phpfreaks.com/topic/125834-download-a-file-with-php-no-direct-link/#findComment-650711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.