File corrupted using multiple upload

Thread is closed for posting
2 posts, 0 answers
  1. jing
    jing avatar
    31 posts
    Member since:
    Aug 2007

    Posted 30 Aug 2010 Link to this post

    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.
  2. jing
    jing avatar
    31 posts
    Member since:
    Aug 2007

    Posted 03 Sep 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top