.NET Ftp View Image

In fact, it is very simple to view pictures through FTP. First, we need to log in to the ftp server according to the user name, password, and server address. 
Then you can pass the name of the corresponding display image on the front end to the background. My front-end display picture is the easyui pop-up box, in fact, only one image tag is needed.
If the code:
<div id="dlg">
    <img src="" id="simg" />
</div>
//js code 
function OclickAttachmentFile() { $('#dlg').dialog({ title: 'Visa Preview' , width: 800, height:650, resizable:true, closed: false, cache: false, modal: true }); var img = new Image(); $(img).bind("load", function () { $("#simg").attr("src", this.src); }); img.src = "/Common/file/GetFileUpload?fillName=" + '@Model.ErpPoMasterExtModel.DeliveryVoucherOriginName'; }

 


 // <summary> // Get the file // </summary> // <param name="fillName">image name</param> // <returns>image name</returns> public FileResult GetFileUpload( string fillName) { string usercConfig = ScmConfig.CusReceiptFtpUser; // Server username string pwdcConfig = ScmConfig.CusReceiptFtpPwd; // Server password string ftpSrccConfig = ScmConfig.CustomerReceiptFtp; // Server address FtpFileBase ftpFileBase = new FtpFileBase(usercConfig, pwdcConfig); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpSrccConfig + fillName); request.Method = WebRequestMethods.Ftp.DownloadFile; // This example assumes the FTP site uses anonymous logon. request.Credentials = new NetworkCredential(usercConfig, pwdcConfig); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); return File(responseStream, "image/jpeg"); }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325140603&siteId=291194637