Re: Memory streams

From: Date: Fri, 13 Jul 2007 13:18:17 +0000
Subject: Re: Memory streams
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-30892@lists.php.net to get a copy of this message
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.

« previous php.internals (#30892) next »