zoukankan      html  css  js  c++  java
  • 引用图片路径,解决同一机器不同虚拟目录之间图片访问

    问题:

    1、同一台机器上部署了两个虚拟目标,A虚拟目录里对图片进行上传删除等操作,图片上传的位置在A虚拟目录中,例如:在AdvertisingImg文件夹中。

    2、而B虚拟目录要求可以看到此图片。虽然是同一台机器,但直接用绝对路径查看图片是不行的。

    解决方法:

    http://localhost/A/AdvertisingImg/图片名称.后缀 

    3、打开绝对路径图片:

      /// <summary>
            /// 下载JPG文件
            /// </summary>    
            /// <param name="strFileFullPath">文件绝对路径路径</param>
            /// <param name="page">下载的页面</param>
            /// <param name="strFileName">要保存的文件名</param>
            public static void DownloadLocalJpgFile(string strFileFullPath, System.Web.UI.Page page,string strFileName)
            {
                System.Web.HttpResponse response = page.Response;
                System.IO.FileInfo file = new System.IO.FileInfo(strFileFullPath);
                if (!file.Exists)
                {              
                    return;
                }
                response.HeaderEncoding = System.Text.Encoding.GetEncoding("gb2312");
                response.Charset = "GB2312";
                response.Clear();
                response.Charset = "GB2312";
                response.ContentEncoding = System.Text.Encoding.UTF8;
                response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName);
                response.AddHeader("Content-Length", file.Length.ToString());
                response.ContentType = "image/jpeg";
                response.WriteFile(file.FullName);
                response.End();
            }

  • 相关阅读:
    CSS使用
    html基础
    面对对象之@classmethod、@staticmethod用法
    验证金额价格的正则表达式
    webstorm 2017.2.2 license server
    Oracle 查询当前系统时间十分钟之前的记录,时间比较SQL
    AngularJS-自定义过滤器 ng-repeat 求和
    封装http请求键值对的js函数
    获取当前的日期时间的js函数,格式为“yyyy-MM-dd hh:mm:ss”
    将金额数字转换为大写汉字的js函数
  • 原文地址:https://www.cnblogs.com/xbding/p/3245028.html
Copyright © 2011-2022 走看看