SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Desert Southwest
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Saving XML to server ~ sent from Flash to PHP

    Hello All ----

    I am relatively new to PHP and need some minor assistance. I am passing from Flash to PHP an XML object which I only need PHP to save on the server. The XML file that is being saved is close to correct but has some extraneous characters inserted (" \ "). I am guessing I need to escape or parse them, but not really sure. Here is my PHP code:

    PHP Code:
    <?php
        $filename 
    "images.xml";
        
    $receivedData $_POST['xmlData'];
     
        
    $fp fopen($filename"w");
        
    fwrite($fp$receivedData);
        
    fclose($fp);
    ?>
    Here is the a sample of the XML that is saved on the server:

    Code:
    <images>
    <album description=\"Description of New Album\" title=\"New Album\" lgPath=\"/\" tnPath=\"gallery//\" tn=\"gallery/sample_tn.jpg\">
    <img title=\"Title Here\" imgName=\"sample.jpg\" />
    </album>
    </images>
    Any help is greatly appreciated. Thanks for any and all replies.

  2. #2
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Staffordshire, UK & Florida, USA
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It could be that the "magic quotes" feature of PHP is quoting your POST data for you. You can check if magic quotes is enabled and if so you can remove the slashes that have been added.

    PHP Code:
    if (get_magic_quotes_gpc())
    {
      
    $receivedData stripslashes($_POST['xmlData']);

    You can find more info here: http://us2.php.net/manual/en/function.stripslashes.php

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Desert Southwest
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by djones
    It could be that the "magic quotes" feature of PHP is quoting your POST data for you. You can check if magic quotes is enabled and if so you can remove the slashes that have been added.

    .......
    That fixed it!

    Thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •