开发者

PHP Return content from remote page

开发者 https://www.devze.com 2022-12-11 09:47 出处:网络
I have for example the following URL: index.php?q=Content/Uploads/Images/1.jpg I want so that pagewill return t开发者_运维知识库he exact result of for this example:

I have for example the following URL:

index.php?q=Content/Uploads/Images/1.jpg

I want so that page will return t开发者_运维知识库he exact result of for this example:

http://www.example.com/Content/Uploads/Images/1.jpg

Note that if 'q' is an image so it should return an image, or if it is a web page so it should return the html and headers of the web page...

Is there any php script that does it?


You will want to use a combination of fpassthru() and header() to do this. You can use the header command to tell the browser what kind of content will be returned (HTML or Image) and fpassthru() to actually return the data.


This script does what you need and more.

Features

* Easy to use.
* Supports Get and Post methods.
* Supports HTTP Basic Authentication - this will work - http://binny:password@example.com/
* Supports both Curl and Fsockopen. Tries to use curl - if it is not available, users fsockopen.
* Secure URL(https) supported with Curl
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号