分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

.NET Ftp查看图片

发布时间:2023-09-06 01:52责任编辑:彭小芳关键词:.NET
其实FTP查看图片很简单,首先我们要根据用户名,密码,还有服务器地址登录上ftp服务器。
然后把前端对应显示图片名称传到后台即可。我前端显示图片是采用的easyui弹框,其实只需一个image标签即可。
如下代码:
<div id="dlg"> ???<img src="" id="simg" /></div>
 
//js代码
function OclickAttachmentFile() { ???????$(‘#dlg‘).dialog({ ?????????????title: ‘签证预览‘, ?????????????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> ???????//获取文件 ???????//</summary> ???????//<param name="fillName">图片名称</param> ???????//<returns>图片流</returns> ???????public FileResult GetFileUpload(string fillName) ???????{ ???????????string usercConfig = ScmConfig.CusReceiptFtpUser; //服务器用户名 ???????????string pwdcConfig = ScmConfig.CusReceiptFtpPwd; //服务器密码 ???????????string ftpSrccConfig = ScmConfig.CustomerReceiptFtp; //服务器地址 ???????????FtpFileBase ftpFileBase = new FtpFileBase(usercConfig, pwdcConfig); ???????????FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpSrccConfig + fillName); ???????????request.Method = WebRequestMethods.Ftp.DownloadFile; ???????????request.Credentials = new NetworkCredential(usercConfig, pwdcConfig); ???????????FtpWebResponse response = (FtpWebResponse)request.GetResponse(); ???????????Stream responseStream = response.GetResponseStream(); ???????????return File(responseStream, "image/jpeg"); ???????}

.NET Ftp查看图片

原文地址:https://www.cnblogs.com/peter1/p/8979173.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved