Results 1 to 4 of 4

Thread: PHP to XML

  1. #1
    Join Date
    Oct 2003
    Location
    here
    Posts
    4

    Angry Unanswered: PHP to XML

    Hi All

    I'm need to write to the end of an XML file and upload a .jpg from a standard HTML form.
    The form only has two fields.
    Code:
    <FORM METHOD="POST" enctype="multipart/form-data" ACTION="">
    <input type="file" name="name" size="24" value=""><BR />
    <textarea name="Copy" COLS=30 ROWS=10></textarea><BR />
    <INPUT TYPE="button" VALUE="Upload File">
    </form>
    The XML looks like this:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <Slides><slideNode jpegURL="tools/selfportraits/independence.jpg"><![CDATA[self portraits 1 copy]]></slideNode>
    <Slides><slideNode jpegURL="tools/selfportraits/self_portrait_wbubbleyum.jpg"><![CDATA[self portraits 2 copy]]></slideNode>
    </Slides>
    I'm not even sure where to start. the other thing is the server doesn't allow c++. would this be easier in PHP, Perl or Java script?

    The good thing is I don't know allot about PHP, Perl or Java script so I get to learn a new language :-)

    Any help would be appreciated.

    thanks
    halcyon32
    Last edited by halcyon32; 10-14-03 at 16:51.

  2. #2
    Join Date
    Oct 2003
    Location
    here
    Posts
    4
    Ok This is where I am at now:
    Code:
    <FORM METHOD="get" enctype="multipart/form-data" ACTION="xmlreader.php">
    <input type="file" name="name" size="24" value=""><BR />
    <textarea name="Copy" COLS=30 ROWS=10></textarea><BR />
    <INPUT TYPE="button" VALUE="Test XML">
    </form>
    PHP Code:
    <?
    $filename 
    "xmloutput.txt";
    $fp fopen$filename,"a+");
    fwrite $fp"$HTTP_RAW_POST_DATA);
    fclose$fp );
    print 
    '<?xml version="1.0"?><Slides>LOGIN OK</Slides>';
    ?>
    the question is why is this not writing to my xmloutput.txt file?
    any help would be appreciated.

    thanks
    halcyon32

  3. #3
    Join Date
    Sep 2003
    Location
    Wisconsin, USA
    Posts
    34

    Error Checking

    You might not have permissions (etc, many other possible reasons) to open that file. What you need is some good old-fashioned error-checking.

    between the fopen line and the fwrite line, add this:

    if ($fp === false) {
    die("Unable to open or create the file");
    }


    At least then you'll have an idea of where the problem is. (If you don't get the error, then you know the file is at least opening.)

  4. #4
    Join Date
    Oct 2003
    Location
    here
    Posts
    4
    thanks Moku for the error checking. It returnd nothing so now my code looks like this:
    PHP Code:
    <?
    file
    $filename 
    "xmloutput.txt";
    $fp fopen$filename,"w+");

    if (
    $fp === false) { 
    die(
    "Unable to open or create the file"); 
    }

    fwrite $fp"$HTTP_RAW_POST_DATA);
    fclose$fp );
    print 
    '<?xml version="1.0"?><result>LOGIN OK</result>';
    ?>
    being my first shot into PHP what should i be setting premissons to. right now i have xmlreader.php set to "664", or rw-rw-r-- and xmloutput.txt set to "777", or rwxrwxrwx is this right?

    thanks
    halcyon32

Posting Permissions

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