Jump to content

[SOLVED] issues downloading a webcam image from other server to web server using curl


Recommended Posts

As I'm using cheap godaddy hosting for my personal website, some php functionality is disabled when it comes to getting files from other servers. I can however use curl. I'm having issues though as the webcam image I'm getting loads slowly and returns an incomplete image, causing errors like this:

 

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/XXX/getAndMake.php5 on line 45

 

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '../images/X.jpg' is not a valid JPEG file in /home/XXX/getAndMake.php5 on line 45

image width = , perhaps there is a problem.

 

I know the script works if I already have a test image there to use. When I look at the "loaded" image, it is 1kb and incomplete. Here is what I'm using that is not working:

 

$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, "http://url/to/webcam/image.jpg");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);

$fileContents = curl_exec($ch);
curl_close($ch);
$fp = fopen("../images/X/X.jpg", "w+"); //placed "X" for demo purposes in this post
fwrite($fp, $fileContents);
fclose($fp);

 

Any ideas on how I can get the full image to load? Am I missing anything in the options (so many possible options)? Thanks for the help. :)

hmmm. sadly I'm getting the same result. It's not like it's timing out either. I get the error messages almost instantly. I also bumped up the timeout from 5 to 30.

 

No sense in hiding it, here are the image links:

on my server (incomplete): http://christopherstevens.cc/images/denv1/originals/chpark1.jpg

 

Result of working conversion here (worked at one point):

http://christopherstevens.cc

 

official image:

http://apcd.state.co.us/psi/chpark.jpg

 

Would you have better luck with the script above? I wonder if it is my hosting or something odd like that.

I just manually downloaded the file, uploaded to the server, and am having other errors. Now I'm wondering if the image format has changed somehow or if I have issues in my script...

 

EDIT------------------

 

There was an error in my script, BUT I fixed it, and am still having the same curl issues. :P Any thoughts?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.