Jump to content


Photo

Curl / GD not working, pulling my hair out!


  • Please log in to reply
3 replies to this topic

#1 markswift

markswift

    Newbie

  • Member
  • Pip
  • 1 posts
  • Main OS: Windows 7

Posted 17 April 2015 - 03:48 AM

Hi Guys,

 

I have the latest version of Uniserver ZeroXL installed and running. I've transferred across from XAMPP and I wanted something lighter and less bloated.

 

The only issue I'm having is that one of my PHP scripts relies on curl and GD to pull images from my IP camera, sadly I cannot get this to work using Uniserver - it works fine with the default install of XAMPP.

 

The message displayed is attached, I've also ensured that both curl and GD are ticked under PHP modules.

 

Any help getting this resolved would be greatly appreciated, I've spent hours googling around and trying various things with no luck...

 

I also tried the following code in check.php and it just displays a blank page.

<?
// is curl installed?
if (!function_exists('curl_init')){ 
die('CURL is not installed!');
}

// create a new curl resource
$ch = curl_init();
echo "OK";
?>

Attached Files



#2 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 17 April 2015 - 05:33 PM

The above example code will not work because you are using short PHP tags Uniform Server defaults to using full PHP tags.

 

The following examples show curl and gd operation on a default installation 11_7_4_ZeroXI

 

curl example save as file z2.php

<?php
$image_url = "http://www.uniformserver.com/ZeroXI_documentation/common/images/us_zero_logo.png";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);

// output to browser
header("Content-type: image/png");
print $image;
?>

gd example save as file z3.php

<?php
    header("content-type: image/png");
    $src_img = imagecreatefrompng("images/logo.png");
    $srcsize = getimagesize("images/logo.png");
    $dest_x = $srcsize[0] / 2;
    $dest_y = $srcsize[1] / 2;
    $dst_img = imagecreatetruecolor($dest_x, $dest_y);

    imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]);
    imagepng($dst_img);
    imagedestroy($src_img);
    imagedestroy($dst_img);
?>

To run type http://localhost/z2.php and http://localhost/z3.php

 

All the best

Ric



#3 Lee Davis

Lee Davis

    Newbie

  • Member
  • Pip
  • 5 posts
  • Gender:Male
  • Location:Montreal, QC, Canada
  • Interests:E-product and Web Development
  • Main OS: Windows 7

Posted 20 July 2017 - 11:10 PM

 

The above example code will not work because you are using short PHP tags Uniform Server defaults to using full PHP tags.

 

The following examples show curl and gd operation on a default installation 11_7_4_ZeroXI

 

curl example save as file z2.php

<?php
$image_url = "http://www.uniformserver.com/ZeroXI_documentation/common/images/us_zero_logo.png";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);

// output to browser
header("Content-type: image/png");
print $image;
?>

gd example save as file z3.php

<?php
    header("content-type: image/png");
    $src_img = imagecreatefrompng("images/logo.png");
    $srcsize = getimagesize("images/logo.png");
    $dest_x = $srcsize[0] / 2;
    $dest_y = $srcsize[1] / 2;
    $dst_img = imagecreatetruecolor($dest_x, $dest_y);

    imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]);
    imagepng($dst_img);
    imagedestroy($src_img);
    imagedestroy($dst_img);
?>

To run type http://localhost/z2.php and http://localhost/z3.php

 

All the best

Ric

 

Is there some set of instructions which CLEARLY state how to activate that can be found ANYWHERE? It's probly me, but I've read every question where there was difficulty with enabling the module, and that stock answer about downloading from PHP.net the same module of PHP as the Uniform Server is about as useful to me as breasts on a man. Can I get a clearcut pointer to some current information? PLEASE?!?!?!?!? 



#4 Lee Davis

Lee Davis

    Newbie

  • Member
  • Pip
  • 5 posts
  • Gender:Male
  • Location:Montreal, QC, Canada
  • Interests:E-product and Web Development
  • Main OS: Windows 7

Posted 27 July 2017 - 12:58 PM

As it turns out...Google IS your friend in this case (lol!). Using the query "curlopt_cainfo option. Uniform Server", I was able to find a clue to my cURL dilemma, as well as anticipate for when I need access to the SSL extension for soon-to-come development. I've changed both the dev and production PHP ini files as I'm not sure which one is the default (posited the dev version, since I'm not using my box as an IIS platform). https://sorastation...._production.ini - jarred loose confusion for me. Just seeing it laid out in front of me, led me to resolve this logjam myself, HTHSO.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users