On Sun, August 5, 2007 1:37 am, Mike wrote: > Hey. My server is running PHP 4(Not actually my server so I don't know > the exact version) and I'm having trouble with getting an image from a > PHP file. Use <?php phpinfo();?> to find out exactly what you've got. > The problem is that originally this system was developed to be used > with PHP 5, and used fopen() and stream_get_contents() to retrieve the > image file from flash_frames.php. I thought I could just replace both > of those with file_get_contents(), but it appears to fail when doing > so. A quick test confirmed that file_get_contents(), when used > locally, returns the PHP source as opposed to the output of the file. If it's old enough, even file_get_contents may not be defined... It first appeared in PHP 4.3.0, so if you're running something earlier than that, upgrade. Or I guess you could use: implode('', file($filename)); > I didn't originally code this (I am but an inheritor who is learning > PHP as he goes :P), so I'm at a loss for what should be done to fix > this. I considered just converting the file into a function that > returns the image, but I cannot find out how to return an image (Or > convert the image to a string of bytes as the original code expected > it to be). > Any help is greatly appreciated. :) > > -Mike > > Original code for retrieving image: > > //Replaces res_viewer to flash_frames since they both take the same > arguments > $img=rawurldecode($img); > $fl_imgsrc=str_replace('/res_viewer.php?','/flash_frames.php?scale='. > $scale.'&',rawurldecode($img)); This is doing rawurldecode() on $img twice, which is almost for sure not right. It probably "works" for all the actual inputs you are using, but it would fail if somebody passed in a filename that happened to have "%xx" in the actual filename, almost for sure. > //Grabs the generated image set up for the flash preview > $handle = fopen($fl_imgsrc, "rb"); > $contents = stream_get_contents($handle); > $fl_map = new SWFBitmap($contents); This is using the Ming extension. There is a Ming mailing list that may be helpful if it turns out that $contents is fine, but the new SWFBitmap is "not working" The number of Ming users is very tiny compared to PHP in general, and I suspect not many hard-core Ming users are on this list. > fclose($handle); -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php