Re: Working with Base64 data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks a bunch! That's what the image should be. I'm running 4.3.2. I'll see
about an upgrade.

steve


"Dvdmandt" <dvdmandt@xxxxxxxxx> wrote in message
news:20040218172552.8421.qmail@xxxxxxxxxxxxxxx
> Did you try with PHP 4.3.4 (I think some earlier version was buggy)? It
> worked, and created something like a black/white palette or something, and
> the number '2' at the bottom, 24x466 px.. :)
>
> Just used this:
> echo base64_decode($image_data);
>
> -- 
> // DvDmanDT
> MSN: dvdmandt¤hotmail.com
> Mail: dvdmandt¤telia.com
> "Steve Goodman" <sgoodman@xxxxxxxxxxxxxxxxxxx> skrev i meddelandet
> news:20040218170745.59547.qmail@xxxxxxxxxxxxxxx
> > Hi everyone,
> > I'm running into an issue decoding base64 data. I have an XML file that
> > contains a base64 encoded image, which I am attempting to extract, and
> > display. Sounds simple enough, yet I am running into an issue saving the
> > image as a jpeg. It seems that when I decode the data, the resulting
> binary
> > image file is invalid.
> >
> > My code:
>
> --------------------------------------------------------------------------
> --
> > -------------------
> > <?php
> > $image_data =
> >
"/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
> > Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAHSABgBAREA/8QAHwAA
> > AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR
> > BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF
> > RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip
> > qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB
> > AAA/APfKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKg3N6n
> > 86Nzep/Ojc3qfzpKKKTcvqPzo3L6j86Ny+o/OuE/4T/S/wDn8j/76o/4T/S/+fyP/vqj/hP9
> > L/5/I/8AvquH/wCFeaN/z7y/9/G/xo/4V5o3/PvL/wB/G/xo/wCFeaN/z7y/9/G/xr0TZB/e
> > /WjZB/e/WjZB/e/Wrm6L/nkv5Ubov+eS/lRui/55L+VO3RelG6L0o3RelY3lyep/Wjy5PU/r
> > R5cnqf1qXY3pRsb0o2N6VqfJ/s0fJ/s0fJ/s14d/ZvxL/wCek3/kP/4qj+zfiX/z0m/8h/8A

> > xVH9m/Ev/npN/wCQ/wD4qvaPsi/3T+dH2Rf7p/Oj7Iv90/nTd1z6j86N1z6j86N1z6j86vfZ
> > x7fnR9nHt+dH2ce351L9oaj7Q1H2hqn8tfU0eWvqaPLX1NN2ye/50bZPf86Nsnv+dS0UUeS3
> > q350eS3q350eS3q351YoooooqbYvpRsX0o2L6U6iiiiinbG9KNjelGxvSpqKKqedJ/cf86PO
> > k/uP+dHnSf3H/Op9if3v1o2J/e/WjYn979aTy29RR5beoo8tvUVLRRRRRXF/8J7J/wBC7rv/
> > AIB//Xo/4T2T/oXdd/8AAP8A+vR/wnsn/Qu67/4B/wD167PavoPyo2r6D8qNq+g/Kloooooo
> > ooorhfClx4avfFM8vhq805YobeWGdLe4V5r996ZnkAO5ghUqJHyXMrkYBDSd1T8D0owPSjA9
> > K//Z";
> >
> > $theFile = base64_decode($image_data);
> > $file = fopen('test.jpg', 'wb');
> > fwrite($file, $theFile);
> > fclose($file);
> > ?>
>
> --------------------------------------------------------------------------
> --
> > ----------------------
> >
> > When I attempt to view the generated test.jpg in a browser, it is unable
> to
> > display. Same with photoshop and the windows built-in pic viewer.
> > I know that the base64 data is not corrupted, since I can get it to
> display
> > properly in netscape with the following code:
> >
> > echo '<img src="data:image/jpeg;base64,'.$image_data.' ">';
> >
> >
> > Unfortunately, I'm tied to IE. Has anyone run into a problem like this
> > before?
> >
> > Thanks!
> > Steve

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux