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 #184067 is a reply to message #184064] Wed, 04 December 2013 03:41 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 12/3/2013 9:26 PM, zhangfj(at)gmail(dot)com wrote:
> 在 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.
>

Don't waste your time. TNP didn't even understand your question, and
his response is way off target. But that's pretty normal for him.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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:24:03 GMT 2024

Total time taken to generate the page: 0.03813 seconds