Click Here
Home Blog Gallery Links Tutorials Projects
[PHP] Curl: Get contents of a remote file and output it to browser 2012-10-05 14:13
Using this script you can get a file to server and send it to the browser.
Quote:
[php]<?php
//get the file (e.g. image) and output it to the browser
$ch = curl_init(); //open curl handle
curl_setopt($ch, CURLOPT_URL, $_GET['url']); //set an url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //do not output directly, use variable
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); //do a binary transfer
curl_setopt($ch, CURLOPT_FAILONERROR, 1); //stop if an error occurred
$file=curl_exec($ch); //store the content in variable
if(!curl_errno($ch))
{
//send out headers and output
header ("Content-Type: ".curl_getinfo($ch, CURLINFO_CONTENT_TYPE)."");
header ("Content-Length: ".curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD)."");
echo $file;
} else echo 'Curl error: ' . curl_error($ch);
curl_close($ch); //close curl handle
?>[/php]
[C++] Adding a program to Startup >>
All Entries

Add a Comment

Get Your IP Instantly
Name:
Enter the text shown in the image (case sensitive):
Email:

The site engine has been coded from scratch. The modules are coded separately eath other.
Server Time: 17:26. Dates and times are shown in Lithuanian (GMT +2) timezone
Name:
Password:

Enter Captcha (Case Sensitive):


Register
English
Lietuviškai

RSS Feed
Main Content
Carmageddon
Programming
Technology
Electronics
Linux
Anything
Site Info

Unique visit count:
3 visits on page.
3514 visits on site.
Detailed Statistics