Writing XML data using ASP.Net
I have successfully written my XML from flash to the server using php. But now I need to have it write to a Windows server using either asp or asp.net. Below is my code for PHP. Have searched allot of places and found how to write text files and lines inside text files. But I use a URL variable to write my XML file name out with xml data I created in Flash as3.
For simplicty I am using localhost... but really is set to my web domain.
On the address line I pass: Example
http://localhost/testing/saveClient.php?ClientFile=myTest.xml
PHP CODE
<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])){
$data = $GLOBALS["HTTP_RAW_POST_DATA"];
$myFileName = $_GET['ClientFile'];
chmod($myFileName, 0777);
$fp = fopen($myFileName, "w+");
fwrite($fp, $data);
fclose($fp);
if(!$fp){
echo("PHP write error. Check permissions.");
}
else{
echo("File Saved");
}
}
?>
FLASH SAMPLE
myURLFile = "http://localhost/testing/saveClient.php?ClientFile=" + ClientFileName;
trace("GLOBAL - writeToDataFile - myURLFile = ", myURLFile);
xmlURLReq = new URLRequest(myURLFile);
xmlSendLoad = new URLLoader();
xmlURLReq.data = userDataXML;
xmlURLReq.contentType = "text/xml";
xmlURLReq.method = URLRequestMethod.POST;
xmlSendLoad.addEventListener(Event.COMPLETE, onWriteData, false, 0, true);
xmlSendLoad.addEventListener(IOErrorEvent.IO_ERROR, onWriteDataIOError, false, 0, true);
xmlSendLoad.load(xmlURLReq);
Thought this would be easier... since I don't know asp that well I am finding it diffcult to save the information.
If anyone can point me to some examples I can take it from there.
HERE IS WHAT I HAVE FOR ASP.
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Save Client File ASPX</title>
<style type="text/css">
body {
font: normal 12px Verdana, Geneva, sans-serif;
color: #666;
}
</style>
<script language="vb" runat="server">
Sub WriteTextStatic()
Dim id As String = Request.QueryString("ClientFile")
Dim objStreamWriter As StreamWriter
Dim strPath As String
strPath = MapPath(id)
objStreamWriter = File.CreateText(MapPath(id))
objStreamWriter.Close()
End Sub
</script>
</head>
<body>
ASPX Page
<% WriteTextStatic() %>
</body>
</html>
Thanks
