Re: Storing binary data within a php script.
| From: | Jamie | Date: | Sun, 19 Dec 2004 10:11:48 +0000 |
| Subject: | Re: Storing binary data within a php script. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204676@lists.php.net to get a copy of this message | ||
Thanks Jed,
Im just trying your method.
If i have any problems ill reply to this post
Jamie
"Jed Smith" <jed@jed.bz> wrote in message
news:20041219032707.14888.qmail@pb1.pair.com...
> This is done in a few examples using base64_encode() and base64_decode().
> A particular OpenGL example I can recall encoded a small (~20k) DLL
> directly into the PHP source that relied upon it, then unpacked it at
> runtime.
>
> Ah, there it is:
>
> ** snip **
>
> if ( is_file( "SimpleWndProc.dll" ) ? filesize( "SimpleWndProc.dll" ) !=
> 2560 : 1 )
> {
> $dll =
> "eNrtVU9IFGEUf7NpTbZue1hCYqlvQT3JslsG0clt/aho1XHNDOnguDutY+uMzh80"
> .
> "KDrYQTPJS1TUoWMEdSpYrEOEsQl66yD9gT1ILCHhIcqDML35Zla3IgO7mQ9+733v"
> /* ... */
> .
> "dxBP8K4dRTzGcY6dBwcd8sBgVupS0lgfi9siXnQPAErZOyqrYXMXwO/8l7oiy5Fv"
> . "kdWIJ8pHfdFAdH90uzf+D/QDFVAQCA==";
>
> $dllout = fopen( "SimpleWndProc.dll", "wb" );
>
> if ( !$dllout )
> die( "Unable to extract SimpleWndProc.dll" );
>
> fwrite( $dllout, gzuncompress( base64_decode( $dll ) ) );
> fclose( $dllout );
>
> ---------------
>
> That's from an iridium example. You just base64 encode the data and
> enclose it in a string. Of course, that's simply one way of doing it.
>
> Jed
>
> Jamie wrote:
>> Hi all,
>>
>> Well so far my attempts to make this work have failed so i thought i
>> would try here. What i have is an installation script that has to write a
>> few files to the webserver. Im trying to cut down on the amount of files
>> that need to be uploaded/modified etc. So what im trying to do is include
>> all the data in one file. What the user then uploads and the physical
>> visual basic program activates the script what in turn sets up the web
>> server side. The problem comes when im trying to handle the ascii values
>> for the binary data. "Warning: Unexpected character in input: ''
>> (ASCII=3) state=2."
>>
>> I basicly have 3 questions.
>>
>> 1) Is it possible to store binary data in text form during transport and
>> then using php's file writing functions to output the file?
>> 2) How would i do it as i guess i have to encode the ascii characters but
>> how would i do that?
>> 3)Is there any better ways you suggest me to do this.
>>
>> Im trying to this for two reasons first is to make the application usable
>> by anyone and the second reason is to try to push the boundarys of the
>> langage.
>>
>> I would like anyones comments and views on this please. Any views might
>> help me come to a result.
>>
>> Thanks
>>
>> Jamie
>
>
> --
> _
> (_)___ Jed Smith, Code Monkey
> | / __| jed@jed.bz | jed@php.net
> | \__ \ +1 541 606-4145
> _/ |___/ Signed mail preferred (PGP 0x703F9124)
> |__/ http://personal.jed.bz/keys/jedsmith.asc