This is a migrated thread and some comments may be shown as answers.

File corrupted using multiple upload

1 Answer 151 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
jing
Top achievements
Rank 1
jing asked on 30 Aug 2010, 10:46 AM
I got this problem when I tried to upload 2 or more file at 1 time. The uploaded files are corrupted. But if upload just 1 file, the uploaded file will be ok. The files were saved in the session so that can be validate at the next page and then save to a document library. I'm using 2009.3.1314.20 version

Here some of the code:
1st Page
aspx:
<telerik:RadUpload ID="Upload1" runat="server" MaxFileInputsCount="5" Width="600px" InitialFileInputsCount="1" ControlObjectsVisibility="RemoveButtons, AddButton" />
<asp:Button ID="Button1" runat="server" Text="OK" OnClick="Button1_Click" />
Codebehind:
private void SaveFilesToSession()
{
    IList list = new List<UploadedFileInfo>();
    foreach (UploadedFile uploadedFile in UploadDocument.UploadedFiles)
    {
        int fileLength = uploadedFile.ContentLength;
        byte[] buffer = new byte[fileLength];
        uploadedFile.InputStream.Read(buffer, 0, fileLength);
      
        UploadedFileInfo info = new UploadedFileInfo();
        info.Name = uploadedFile.GetName().Trim();
        info.FileInByte = buffer;
        info.ContentLength = uploadedFile.ContentLength;
        list.Add(info);
    }
  
    Session["UploadedFiles"] = list;
}
  
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
    SaveFilesToSession();
    Response.Redirect("Upload2.aspx");
}

Thanks in advanced.

1 Answer, 1 is accepted

Sort by
0
jing
Top achievements
Rank 1
answered on 03 Sep 2010, 10:36 AM
I got it work by saving the file (byte[]) in session in Page_Load then proceed to do the serverside validation and redirect to another page.
Tags
Upload (Obsolete)
Asked by
jing
Top achievements
Rank 1
Answers by
jing
Top achievements
Rank 1
Share this question
or