FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Can I download file with address like this "http://***.com/file.php/ABC.html" automatically ?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Can I download file with address like this "http://***.com/file.php/ABC.html" automatically ? [message #184064 is a reply to message #184031] Wed, 04 December 2013 02:26 Go to previous messageGo to previous message
zhangfj is currently offline  zhangfj
Messages: 5
Registered: December 2013
Karma:
Junior Member
在 2013年12月3日星期二UTC+8下午6时09分34秒,The Natural Philosopher写道:
> On 03/12/13 03:10, zhangfj(at)gmail(dot)com wrote:
>
>> Thank you for your informative reply.
>
>>
>
>> Briefly, my problem is that I can't download the file by programming.
>
>> I want to change "ABC" in the URL to download files automatically from one site.
>
>>
>
>
>
> You need to have a link top a PHP program that reads the file, then sets
>
> up headers top tell the browser that it is not (to be understood to be)
>
> an HTML: page, but a file download, and then sends the file.
>
>
>
> so if your program was say -getfile.php and the file was 'rubbish.html'
>
>
>
> <?php
>
> header("Content-Disposition: attachment; filename=\"rubbish.html\"");
>
> header("Content-Type: text/plain");
>
> $data=file_get_contents("rubbish.html");
>
> echo($data);
>
>
>
> and that's it. No closing ?> should be used so there is no danger of
>
> setting characters NOT in the file itself - the script exits still in
>
> 'php mode'
>
>
>
> in your main page use
>
>
>
> <a href="getfile.php">Download the file here</a>
>
>
>
> Setting the content-disposition to 'attachment' strongly suggests to the
>
> browser that the contents should not be displayed as HTML but should be
>
> downloaded instead. However this behaviour is never 100% guaranteed.
>
>
>
> instead of a local filename you can use a URL as well, if you are trying
>
> to 'scrape' another website.
>
>
>
> curl() will give you more control if you need it than
>
> file_get_contents() for that.
>
>
>
> http://us1.php.net/manual/en/curl.examples-basic.php
>
>
>
>
>
> --
>
> Ineptocracy
>
>
>
> (in-ep-toc’-ra-cy) – a system of government where the least capable to
>
> lead are elected by the least capable of producing, and where the
>
> members of society least likely to sustain themselves or succeed, are
>
> rewarded with goods and services paid for by the confiscated wealth of a
>
> diminishing number of producers.

Thanks for your information in detail, I can't understand them now. I will pay attention to that website to follow your idea.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: foreach as list
Next Topic: illegal offset problem
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 19:46:52 GMT 2024

Total time taken to generate the page: 0.50342 seconds