Calling C# from JavaScript with parameters
<p>I'm using source files found at <a href="http://www.thecssninja.com/javascript/gmail-upload" rel="nofollow">http://www.thecssninja.com/javascript/gmail-upload</a> (all credit goes to CSSNinja for the code).  And what I'm having an issue with is I basically need to convert a section of this JavaScript to interface with C#, the problem is i really don't know JavaScript. I need to be able to save the files to specific directories with specific file names based on Session variables.  Current the script calls a simple php, and I don't know how to use PHP to interface with Sessions.  Any help would be awesome.</p>

<pre><code>xhr.open("POST", "upload.php");
xhr.setRequestHeader("If-Modified-Since", "Mon, 26 Jul 1997 05:00:00 GMT");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", file.fileName);
xhr.setRequestHeader("X-File-Size", file.fileSize);
xhr.setRequestHeader("Content-Type", "multipart/form-data");
xhr.send(file);
</code></pre>

<p>The question is basically how to convert the above to interface with a class in C#, passing in any/one parameter that is above.</p>

<p>PHP code</p>

<pre><code>&lt;?php
$headers = getallheaders();
// create the object and assign property
$file = new stdClass;
$file-&gt;name = basename($headers['X-File-Name']);
$file-&gt;size = $headers['X-File-Size'];
$file-&gt;content = file_get_contents("php://input");

// if everything is ok, save the file somewhere
echo $file-&gt;content;    
</code></pre>

<p>?></p>
