summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Hughes <sterling@bumblebury.com>2001-05-31 11:59:39 +0000
committerSterling Hughes <sterling@bumblebury.com>2001-05-31 11:59:39 +0000
commit3d54ba1b9e4219e501019361d49c3fcfc0aafc0b (patch)
tree69fcda91d246c7e97745e195a72de0043a9717a1
parente051f904f2bb80474277ad792ee6077126b8890a (diff)
downloadgnurl-3d54ba1b9e4219e501019361d49c3fcfc0aafc0b.tar.gz
gnurl-3d54ba1b9e4219e501019361d49c3fcfc0aafc0b.tar.bz2
gnurl-3d54ba1b9e4219e501019361d49c3fcfc0aafc0b.zip
Add the getbinarypageinvar.php, which shows how to use the
CURLOPT_BINARYTRANSFER, added in PHP 4.0.6 along with the CURLOPT_RETURNTRANSFER option.
-rw-r--r--php/examples/getbinarypageinvar.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/php/examples/getbinarypageinvar.php b/php/examples/getbinarypageinvar.php
new file mode 100644
index 000000000..52e542c3d
--- /dev/null
+++ b/php/examples/getbinarypageinvar.php
@@ -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 );
+?>