ultrus Posted April 18, 2008 Share Posted April 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/101723-solved-issues-downloading-a-webcam-image-from-other-server-to-web-server-using-curl/ Share on other sites More sharing options...
Daniel0 Posted April 18, 2008 Share Posted April 18, 2008 Try to set CURLOPT_BINARYTRANSFER to true. Quote Link to comment https://forums.phpfreaks.com/topic/101723-solved-issues-downloading-a-webcam-image-from-other-server-to-web-server-using-curl/#findComment-520446 Share on other sites More sharing options...
ultrus Posted April 18, 2008 Author Share Posted April 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/101723-solved-issues-downloading-a-webcam-image-from-other-server-to-web-server-using-curl/#findComment-520457 Share on other sites More sharing options...
ultrus Posted April 18, 2008 Author Share Posted April 18, 2008 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. Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/101723-solved-issues-downloading-a-webcam-image-from-other-server-to-web-server-using-curl/#findComment-520470 Share on other sites More sharing options...
ultrus Posted April 18, 2008 Author Share Posted April 18, 2008 Ah! If I load the incomplete image in a text editor, I get this: Object Moved This document may be found here "here" is a link to the image. This gets me further. How would I solve this? Quote Link to comment https://forums.phpfreaks.com/topic/101723-solved-issues-downloading-a-webcam-image-from-other-server-to-web-server-using-curl/#findComment-520510 Share on other sites More sharing options...
ultrus Posted April 18, 2008 Author Share Posted April 18, 2008 The soluction: curl_setopt ($ch,CURLOPT_FOLLOWLOCATION,1); Thanks all. All is fixed. Quote Link to comment https://forums.phpfreaks.com/topic/101723-solved-issues-downloading-a-webcam-image-from-other-server-to-web-server-using-curl/#findComment-520515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.