I am using the FileUpload control to upload a large file. Everything works fine on localhost, but the file is damaged on the server: the download is going well, the file is the right size, but the contents are mixed, some parts of the file are written on top of others.
eg. eg:
Original file: abcdef0123456789 Uploaded file: abc1230123456789
There is approximately one segment, such as a 10 MB file, the length changes, usually 0.1-1 kB.
My code is simple:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UploadTest.Default" %> <!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 runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> </div> <p> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" /> </p> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </form> </body> </html>
And the server side:
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace UploadTest { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { FileUpload1.SaveAs(AppDomain.CurrentDomain.BaseDirectory + "\\Files\\" + FileUpload1.FileName); Label1.Text = "Success " + FileUpload1.FileName; } else { Label1.Text = "No file"; } } } }
It doesnโt matter which file I am trying to download, large (> 10 MB) get corrupted.
I think this has nothing to do with the code, but it is related to something else (but it does not happen on my client computer, and I need a simple enough solution to explain it to another person using it if it is related to by customer). I tried to disable antivirus software and it didnโt affect. But there are also some clients that handle data loading correctly.
What else could ruin my data?
Any ideas? Thanks, AlesP
Post has been edited.
alesp source share