image in XML file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    image in XML file

    I've some XML files used to update my datas in my database/server.

    I've got how to retrieve all datas between xml tags, but I'm stuck when I've
    to retrieve images datas:

    <DATAS>
    .....
    <PICTURES number=3 encoded=0> //0 is for plain jpg, 1 is for CDATA
    Base64 string
    <PIC name=pic1344_1. jpg number=1>
    .....
    </PIC>
    </PICTURES
    </DATAS>

    how to save the image on the server ?

    bob


  • Terence

    #2
    Re: image in XML file

    Bob Bedford wrote:
    [color=blue]
    > I've some XML files used to update my datas in my database/server.
    >
    > I've got how to retrieve all datas between xml tags, but I'm stuck when I've
    > to retrieve images datas:
    >
    > <DATAS>
    > .....
    > <PICTURES number=3 encoded=0> //0 is for plain jpg, 1 is for CDATA
    > Base64 string
    > <PIC name=pic1344_1. jpg number=1>
    > .....
    > </PIC>
    > </PICTURES
    > </DATAS>
    >
    > how to save the image on the server ?
    >
    > bob
    >
    >[/color]

    put your base64 string inside a cdata tag
    <pic>
    <![CDATA[
    ....insert base64 string here...
    ]]>
    </pic>

    Comment

    • Bob Bedford

      #3
      Re: image in XML file

      Hi Terence, thanks for replying
      [color=blue]
      > put your base64 string inside a cdata tag
      > <pic>
      > <![CDATA[
      > ...insert base64 string here...
      > ]]>
      > </pic>[/color]

      The CDATA tag already exists. My problem is what to do with it !

      Do I have to put the base64 string in a $variable then save it in a file,
      most probably I must decode the base64 string....my problem is once I
      encounter this tag, what should I do !

      I've looked in php.net and google, but couldn't find any answer.

      Bob


      Comment

      • Lāʻie Techie

        #4
        Re: image in XML file

        On Tue, 17 Aug 2004 09:37:46 +0200, Bob Bedford wrote:
        [color=blue]
        > Hi Terence, thanks for replying
        >[color=green]
        >> put your base64 string inside a cdata tag <pic>
        >> <![CDATA[
        >> ...insert base64 string here...
        >> ]]>
        >> </pic>[/color]
        >
        > The CDATA tag already exists. My problem is what to do with it !
        >
        > Do I have to put the base64 string in a $variable then save it in a file,
        > most probably I must decode the base64 string....my problem is once I
        > encounter this tag, what should I do !
        >
        > I've looked in php.net and google, but couldn't find any answer.
        >
        > Bob[/color]

        After reading the characters within the PIC tag (btw, why are all your
        tags uppercase?) into a $variable, you may need to decode it (look at your
        encoded attribute of the PICTURES tag). At this point, you have the image
        data and file name. Open a file output stream, set the binary mode on the
        stream, write the image data, then close the stream (this should
        automatically flush the stream).

        HTH,
        La'ie Techie

        Comment

        Working...