RE: [PHP] Problems with file_get_contents() and local PHP file
| From: | Jan Reiter | Date: | Sun, 05 Aug 2007 11:14:17 +0000 |
| Subject: | RE: [PHP] Problems with file_get_contents() and local PHP file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260202@lists.php.net to get a copy of this message | ||
Hi!
If you want file_get_contents() to open the compiled data, force the server
to compile it first. ;-)
Do not open the file from filesystem, use the ULR
(http://server/flash_frames.php?...).
For this fopen() wrappers have to be enabled.
http://www.php.net/manual/en/function.file-get-contents.php
The tip in the blue box.
If you get uncompiled code with the url stated, you got a big security hole
in the server config!!
Hope this is, what you are searching for ...
Jan
-----Original Message-----
From: Mike [mailto:zmen8@msn.com]
Sent: Sunday, August 05, 2007 8:38 AM
To: php-general@lists.php.net
Subject: [PHP] Problems with file_get_contents() and local PHP file
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);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php