Customize link data via PHP?

I want to be able to go to mydoma.in/tunnel.php?file=http://otherdoma.in/music.mp3and then transfer the data http://otherdoma.in/music.mp3transferred to the client.

I tried to do this with Header();, but redirects it instead of overlaying the data.

How can i do this?

+3
source share
3 answers

Use cURL to stream:

<?php

$url = $_GET["file"];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);

curl_exec($ch);
curl_close($ch);

?>
+1
source

Ask your PHP script to retrieve the remote content:

$data = file_get_contents($remote_url);

And then just spit it out:

echo $data;

Or simply:

echo file_get_contents($remote_url);

You may need to add some headers to indicate the type of content.

- nginx - URL- , .

0

, file_get_contents(). , , cURL. cURL URL- "get" get. PHP. header(), . , , . , , cron .

0

All Articles