Some times PDF files get corrupted after File Upload C# Azure VM RRS feed

  • Question

  • User-733996868 posted

    I am trying to upload PDF files. Only sometimes uploaded file gets corrupt. When I open that file on Adobe or browser. it says Insufficient data for images.

    Error On PDF

    This problem is not for all the uploads. When I tried to upload the same file again its works perfectly. I am not able to replicate the issue so that I can know why this type of issue occurring I am using below code to save the file

    FileUpload upload = GridView1.Rows[index].FindControl("FileUpload1") as FileUpload;
    if (upload.HasFile)
         string nameoffile = upload.FileName;
         Random ran = new Random();
         int forReference = ran.Next();
         string[] strfileArray = nameoffile.Split('.');
         nameoffile = strfileArray[0] + "" + forReference + ".pdf";
         upload.SaveAs(path + "/" + nameoffile);
         upload.SaveAs(path + "/" + nameoffile);
    Note: We are running this appliaction on Azure VM. This code was works without any issue on previous server. since we migrated to Azure Windows server
    Monday, June 12, 2017 5:57 AM

All replies

  • User753101303 posted


    If no file is posted for the current row, it seems you are reusing the last file name possibly overwriting the previous file? The next time it happens I would check the size of the file to see if it is 0.

    Monday, June 12, 2017 11:10 AM