Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
369 views
in Technique[技术] by (71.8m points)

asp.net - Some times PDF files get corrupted after File Upload C#

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

Error 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);
}
else
{
     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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

We had hosted application on C drive of azure VM. After Changing application to secondary storage i.e. D drive problem got resolved


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...