On Fri, Jul 13, 2007 at 16:02:40 +0300, Adrian Drumea wrote:
> Hello,
>
> I'm new to this list, so I aplogize if this is not the place to
> post this message.
>
> I was using today the getimagesize() function which takes a file
> name. I was trying to take the size of an image decoded using
> base64_decode from a string. So I have my decoded data in $data.
> Now to apply getimagesize() I need a file, so I saved $data to
> a temporary file and everything worked. I then tried to avoid
> the temporary file by using i/o streams, but I didn't manage to
> do this.
>
> Correct me if I am wrong, but from what I see there is no way
> to create a memory stream using php://memory and also attach
> a unique key to it. If that would be possible, I could create
> a memory stream with a unique key, write the data into it and
> then pass this memory stream name to the getimagesize() function.
>
> In this way, all functions requiring a file could be used on
> a memory buffer.
You could implement your own stream with stream_wrapper_register(), and
then use URLs like "mycustomstream://12345678", and your stream
implementation could then extract the "12345678" part to use as a key,
for example.