开发者

Using plupload control with .NET

I downloaded the source project from the website, using as is, except I changed the target file from upload.php to upload.aspx, which contains the following code to receive the file data:

        int ch开发者_开发知识库unk = Request.QueryString["chunk"] != null ? int.Parse(Request.QueryString["chunk"]) : 0;
        string fileName = Path.GetFileName(Request.Files[0].FileName);

        // Read stream
        BinaryReader br = new BinaryReader(Request.InputStream);
        byte[] buffer = br.ReadBytes((int)br.BaseStream.Length);
        br.Close();
        //byte[] appended = buffer.Take(149).ToArray();

        // Write stream
        BinaryWriter bw = new BinaryWriter(File.Open(Server.MapPath("~/uploadfiles" + fileName), chunk == 0 ? FileMode.Create : FileMode.Append));
        bw.Write(buffer);
        bw.Close();

The problem is when I upload a jpg file, or any other file, there is data prepended and appended to every chunk, that obviously makes the file corrupted, and increases the file size. Any idea why that would happen?


You ned to read from Request.Files[0] not from Request.InputStream.

see marco's post: here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜