mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Add the getbinarypageinvar.php, which shows how to use the
CURLOPT_BINARYTRANSFER, added in PHP 4.0.6 along with the CURLOPT_RETURNTRANSFER option.
This commit is contained in:
parent
e051f904f2
commit
3d54ba1b9e
25
php/examples/getbinarypageinvar.php
Normal file
25
php/examples/getbinarypageinvar.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// Allocate a new cURL handle
|
||||
$ch = curl_init("http://www.designmultimedia.com/intro.jpg");
|
||||
if (! $ch) {
|
||||
die( "Cannot allocate a new PHP-CURL handle" );
|
||||
}
|
||||
|
||||
// We'll be returning this transfer, and the data is binary
|
||||
// so we don't want to NULL terminate
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
|
||||
|
||||
// Grab the jpg and save the contents in the $data variable
|
||||
$data = curl_exec($ch);
|
||||
|
||||
// close the connection
|
||||
curl_close($ch);
|
||||
|
||||
// Set the header to type image/jpeg, since that's what we're
|
||||
// displaying
|
||||
header("Content-type: image/jpeg");
|
||||
|
||||
// Output the image
|
||||
print( $data );
|
||||
?>
|
Loading…
Reference in New Issue
Block a user