|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13960 ImageCreateFromJPEG doesn't work with URLs
Submitted: 2001-11-06 14:36 UTC Modified: 2001-12-13 06:28 UTC
From: S dot G dot Spencer at warwick dot ac dot uk Assigned:
Status: Closed Package: GD related
PHP Version: 4.0.6 OS: Windows XP
Private report: No CVE-ID: None
 [2001-11-06 14:36 UTC] S dot G dot Spencer at warwick dot ac dot uk
The following code should give me the image served by my webcam server:

$cam = ImageCreateFromJPEG('http://localhost:69/');

But instead gives me:

Warning: imagecreatefromjpeg: Unable to open 'http://localhost:69/' for reading in c:\program files\apache\htdocs\webcam\cam.php
If, however, I create a local copy of the output of the server, like this:

$in = fopen('http://localhost:69/','rb');
$out = fopen('tempcam.jpg','wb');
while ( !feof($in) ) {
 $temp = fread ($in, 4096);
fclose ($in); fclose($out);

and then use ImageCreateFromJPEG on that file instead of the URL, it works perfectly.

Therefore, ImageCreateFromJPEG doesn't re-use the fopen code correctly (as it should and is hinted to by the manual page saying that ImageCreateFromJPEG can open files or URLs).

Bug 6825 seems to be similar, but for PHP 4.0.2. The bug was closed as it was allegedly fixed, but now seems to have re-surfaced.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-10 20:09 UTC]
Works fine for me on Linux. Could you please try
with some external jpg? ie. Not on localhost?

 [2001-11-12 06:40 UTC] S dot G dot Spencer at warwick dot ac dot uk
Still has the same problem on Windows XP with a jpeg on an external server, but as you say, it works fine on the Linux version (tested on a snapshot build on my Cobalt Qube server).
 [2001-11-18 19:10 UTC]
What if you use instead of localhost ?


 [2001-12-13 06:28 UTC]
No feedback. Closing.
 [2002-07-27 12:03 UTC] midg3t at mail dot com
I have the same problem. I am using PHP 4.2.2 (SAPI, not CGI) with Apache 1.3.26 on Windows 2000. Whether I use GD 1 or 2 (the versions supplied with PHP 4.2.2) there is still a problem reading JPEGs from URLs.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 03:03:50 2022 UTC