Problems with file_get_contents() and local PHP file
| From: | Mike | Date: | Sun, 05 Aug 2007 06:37:54 +0000 |
| Subject: | Problems with file_get_contents() and local PHP file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-260200@lists.php.net to get a copy of this message | ||
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.
I have a file, flash_frames.php, which outputs an image composed of
the combination of a bunch of other images. Another file, flash.php,
takes this image and chops it up into frames and then animates it in a
flash file.
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.
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));
//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);
fclose($handle);