Created
June 28, 2011 04:19
-
-
Save maxim75/1050481 to your computer and use it in GitHub Desktop.
Plupload - handling POST request in ASP.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chunk = Request.Form["chunk"] != null ? int.Parse(Request.Form["chunk"]) : 0; | |
var fileName = Request.Form["name"] ?? ""; | |
//open a file, if our chunk is 1 or more, we should be appending to an existing file, otherwise create a new file | |
var fs = new FileStream(Server.MapPath("/files/" + fileName), chunk == 0 ? FileMode.OpenOrCreate : FileMode.Append); | |
//write our input stream to a buffer | |
var buffer = new Byte[Request.Files[0].InputStream.Length]; | |
Request.Files[0].InputStream.Read(buffer, 0, buffer.Length); | |
//write the buffer to a file. | |
fs.Write(buffer, 0, buffer.Length); | |
fs.Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment