PHP script to RECEIVE XML documents?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JavaKinetic
    New Member
    • May 2007
    • 1

    #1

    PHP script to RECEIVE XML documents?

    I am wondering what the best way is to have my Apache/PHP server accept an XML file that is sent using an ASP Send function. My client is using ASP to send a .5 to 2MB XML string, which I must accept and save to disk.

    I have built the webpages to do this with user interaction (ie: click to add a file, and upload by clicking submit), but I am stumped on how to do this through an automated means. I must be missing something really simple. Any thoughts? Cheers!


    '-------- ASP CODE THAT SENDS TO OUR PHP SERVER... --------

    ' *** Set up a command to send an XML file to a remove server ***
    ' *** - Includes MP3 file Base64 encoded

    RawDir=Server.M apPath("/UserContent/" & NMD("CampaignID ")) & "\Voice\"
    RS.Open "SELECT * FROM UserContent WHERE ContentID=" & ContentID ,
    objApp.DB,adOpe nStatic,adLockO ptimistic,adCmd Text

    ' *** Create XML object ***
    Set objXMLDoc = Server.CreateOb ject("Msxml2.DO MDocument.3.0")
    objXMLDoc.loadX ML "<InstallVo ice />"

    Set oRoot = objXMLDoc.docum entElement

    ' *** Set up a bunch of elements here ..
    / 8< snip 8<

    ' *** Read the file into the stream ***
    Set oRoot = objXMLDoc.docum entElement
    Set objStream = Server.CreateOb ject("ADODB.Str eam")
    objStream.Type = 1
    objStream.Open
    objStream.LoadF romFile RawDir & RS("UploadFile" )

    ' *** Do base64 encoding for an MP3 file ***
    Set oElement = objXMLDoc.creat eElement("FileC ontents")
    oElement.dataTy pe = "bin.base64 "
    oElement.nodeTy pedValue = objStream.Read
    oRoot.appendChi ld oElement

    Set xmlhttp = Server.CreateOb ject("MSXML2.Se rverXMLHTTP")
    xmlhttp.open "POST", "http//myhostsomewhere .com/uploader.php", false

    ' *** Send the file up ***
    xmlhttp.send objXMLDoc.XML

    ' *** Close down the effort....
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    If the file exists and is accesible, then you can open, read, write to the file using PHP file functions from a sript running on a scheduled task.

    Comment

    Working...