I see a couple of spots for problems in what you are doing. When you're compressing the data, you are basically transforming text strings to binary. I mean, text is binary data, but generally strings cannot contain NUL characters (that is a 0 value), because that's traditionally reserved to mark the end of the string. On the other hand, 0 is a perfectly legal value in a "binary context" (so to speak) and I think you'll probably get some 0's in the compressed data (or at least, I'm not sure if you could be sure you won't, under any circumstance). So, when you're posting data (except you post as binary), NULs will be a problem, because the data (the string) will be truncated.
>From the php side, I think you should use the gzinflate function, as the ByteArray class uses inflate / deflate (from zlib). I haven't used it in php, just found it in the manual: http://ar.php.net/manual/en/function.gzinflate.php The signature of the function says it takes a string, so should probably check what happens if you have embbeded NULs here too... (my guess is that php will also truncate the data). You could try to post the data as binary and see if it works, but I'd first check that the uncompressing is working on the php side. A quick and dirty idea: you could check this by dumping the compressed ByteArray in the Flash IDE, for instance, to the trace output, in the form of a php assignment. I.e, printing something like $data = chr(someNumber) . chr(someOtherNumber) . chr(someOtherNumber); Then paste that in your php file and try to get the uncompressed data hardcoding the generated php assignment. If you get that right, then you know the only remaining problem is passing the data itself to php in a "safe" way. Or you could even encode it as base64 (which is used precisely to avoid the embedded NULs problem); decoding from the php side is just a matter of calling base64_decode(); from the AS side, you don't have anything builtin, but there are classes for encoding base64 around (I wrote one some time ago). Of course, using base64 would add more overhead and will add to the size of the data you're posting (1/3 of the unencoded size), but maybe it turns out to be simpler than grabbing the binary data from php. Cheers Juan Pablo Califano 2008/10/2, Benny <[EMAIL PROTECTED]>: > > I am sending a compressed bytearray to PHP: > > > > var XMLOut:ByteArray = new ByteArray(); > > XMLOut.writeUTFBytes("<root><item1>just an example</item1></root>"); > > XMLOut.compress(); > > . cut . > > > > The data is POSTed (with URLLoader in var XMLString) to > mydomain.com/save.php: > > > > <?php > > $XMLString = gzuncompress($_POST["XMLString "]); > > $handle = fopen("content/test.xml", "w+b"); > > fwrite($handle, $ XMLString); > > fclose($handle); > > ?> > > > > The result of this is that test.xml is being created but without any > content. > > (BTW: If I leave out the compression/decompression part then the file is > created with the expected content) > > > > Should this actually work with gzuncompress and if so why might it be > failing here? > > Or should the uncompressioning be handled differently? > > > > > > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders