本文介绍了如何在iframe中显示从ftp服务器恢复的pdf或图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想在IFrame控件中显示从FTP服务器检索到的pdf或图像文件 我尝试过: string ParentFolder = ConfigurationManager.AppSettings [ DocReqFolder]。ToString(); int l = filePath.IndexOf(' 。')+ 1 ; string Extn = filePath.Substring(l); Ftp_FileHandler Ftp = new Ftp_FileHandler(); Ftp.FtpPath_withCredents(); Ftp.FTP_DownloadFile(filePath,ParentFolder); var context = System.Web.HttpContext.Current; context.Response.Clear(); context.Response.AddHeader( Content-Disposition, attachment; filename = + filePath); if (Extn.Contains( PDF )== true || Extn.Contains( pdf)== true ) HttpContext.Current.Response.ContentType = application / pdf; else HttpContext.Current.Response.ContentType = 应用/八位字节流; context.Response.OutputStream.Write(Ftp.file, 0 ,Ftp.file.Length); context.Response.End(); 解决方案 I want to show pdf or image file retreived from FTP server in IFrame controlWhat I have tried:string ParentFolder = ConfigurationManager.AppSettings["DocReqFolder"].ToString(); int l = filePath.IndexOf('.') + 1; string Extn = filePath.Substring(l); Ftp_FileHandler Ftp = new Ftp_FileHandler(); Ftp.FtpPath_withCredents(); Ftp.FTP_DownloadFile(filePath, ParentFolder); var context = System.Web.HttpContext.Current; context.Response.Clear(); context.Response.AddHeader("Content-Disposition", "attachment; filename=" + filePath); if (Extn.Contains("PDF") == true || Extn.Contains("pdf") == true) HttpContext.Current.Response.ContentType = "application/pdf"; else HttpContext.Current.Response.ContentType = "application/octet-stream"; context.Response.OutputStream.Write(Ftp.file, 0, Ftp.file.Length); context.Response.End(); 解决方案 这篇关于如何在iframe中显示从ftp服务器恢复的pdf或图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!