So if you are using the uploadify control you should have something in your markup like this:
<script type="text/javascript">
// <![CDATA[
var id = "55";
var theString = "asdf";
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader': 'uploadify/uploadify.swf',
'script': 'Upload.ashx',
'scriptData': { 'id': id, 'foo': theString},
'cancelImg': 'uploadify/cancel.png',
'auto': true,
'multi': true,
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
'queueSizeLimit': 90,
'sizeLimit': 4000000,
'buttonText': 'Choose Images',
'folder': '/uploads',
'onAllComplete': function(event, queueID, fileObj, response, data) {
}
});
});
// ]]></script>
<input id="fileInput" name="fileInput" type="file" />
Then you want to have a Generic Handler, which is an ashx file. What happens is this handler gets called when the uploadify control wants to upload one of the files in the Queue that it has. Open VS -> Right click your project -> Add New -> Choose Generic Handler -> Name it something like Upload.ashx.
Take that file and put something similar to this in there:
public class Upload : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
try
{
HttpPostedFile file= context.Request.Files["Filedata"];
int id = (Int32.Parse(context.Request["id"]));
string foo = context.Request["foo"];
file.SaveAs("C:\\" + id.ToString() + foo + file.FileName);
context.Response.Write("1");
}
catch(Exception ex)
{
context.Response.Write("0");
}
}
}
It comes by default with an IsReusable()...DONT DELETE IT. Its required, just leave it in there or you will get a strange error.
Also, you can watch it step by step here: http://casonclagg.com/articles/6/video-tutorial-uploadify-asp-net-c-sharp.aspx
EDIT
I think you want to do this, where file is a HttpPostedFile object:
BinaryReader b = new BinaryReader(file.InputStream);
byte[] binaryData = b.ReadBytes(file.InputStream.Length);