Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:30892 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69000 invoked by uid 1010); 13 Jul 2007 13:43:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68984 invoked from network); 13 Jul 2007 13:43:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2007 13:43:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=frode@CoreTrek.no; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=frode@CoreTrek.no; sender-id=unknown Received-SPF: error (pb1.pair.com: domain CoreTrek.no from 80.239.119.81 cause and error) X-PHP-List-Original-Sender: frode@CoreTrek.no X-Host-Fingerprint: 80.239.119.81 ragnaros.coretrek.no Received: from [80.239.119.81] ([80.239.119.81:54939] helo=ragnaros.coretrek.no) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/92-32782-CCB77964 for ; Fri, 13 Jul 2007 09:19:10 -0400 Received: from localhost (localhost [127.0.0.1]) by ragnaros.coretrek.no (Postfix) with ESMTP id 885BA198470; Fri, 13 Jul 2007 15:22:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at ragnaros.coretrek.no Received: from ragnaros.coretrek.no ([127.0.0.1]) by localhost (ragnaros.coretrek.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JnnmitAD4u-N; Fri, 13 Jul 2007 15:22:35 +0200 (CEST) Received: from enterprise.intra.coretrek.com (phobos.coretrek.no [80.239.119.10]) by ragnaros.coretrek.no (Postfix) with ESMTP id 3C24D198485; Fri, 13 Jul 2007 15:22:35 +0200 (CEST) Received: from fearless.intra.coretrek.com (enterprise.intra.coretrek.com [10.0.0.2]) by enterprise.intra.coretrek.com (8.13.1/8.11.0) with ESMTP id l6DDJ20A042245; Fri, 13 Jul 2007 15:19:02 +0200 (CEST) (envelope-from frode@CoreTrek.no) Received: by fearless.intra.coretrek.com (Postfix, from userid 1001) id 0778042C9EA; Fri, 13 Jul 2007 15:18:17 +0200 (CEST) Date: Fri, 13 Jul 2007 15:18:17 +0200 To: Adrian Drumea Cc: internals@lists.php.net Message-ID: <20070713131817.GE9779@fearless.intra.coretrek.com> References: <001301c7c54e$1a982cd0$0200000a@server> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001301c7c54e$1a982cd0$0200000a@server> X-Operating-System: Debian GNU/Linux Unstable (sid) i386 X-PGP-Key: http://corehacker.com/~frode/gpg/ X-PGP-Key-FingerPrint: DA78 4CFF E1E5 068A 9B33 11F4 5DFE 74D0 3907 BED0 User-Agent: Mutt/1.5.16 (2007-06-11) Subject: Re: [PHP-DEV] Memory streams From: frode@CoreTrek.no ("Frode E. Moe") 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.