zoukankan      html  css  js  c++  java
  • C# 获取临时素材

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.Xml;
    using System.Net;
    
    
    public partial class ssss : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Save_Photo();
        }
    
        protected void Save_Photo()
        {
            try
            {
                string media_id = SSRequest.GetFormString("media_id");
                string[] data = media_id.Split(',');
                string returnda = "{"success":"true","data":[";
                string aaa = "";
                string fileName = PublicMethod.GetUserIdByWxId(urlkey.GetCookie("wzcookie", "opid"));
                Directory.CreateDirectory("绝对路径" + fileName + "");
                for (int i = 0; i < data.Length; i++)
                {
                    //文件重命名
                    string reName = DateTime.Now.ToString("yyyMMddHHmmssfff");
                    string url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=" + WXHelper.ACCESS_TOKEN(peizhi.appid(), peizhi.appsecret()) + "&media_id=" + data[i];
                    WebClient mywebclient = new WebClient();
                    //下载文件到本地
                    mywebclient.DownloadFile(url, Utils.GetMapPath("/uploadfile/" + fileName + "/" + reName + ".jpg"));
    
                    string str = reName + ".jpg";
    
                    if (i + 1 == data.Length)
                    {
                        aaa += """ + str + """;
                    }
                    else
                    {
                        aaa += """ + str + "",";
                    }
    
                }
                returnda += aaa+"]}";
    
                Response.Write(returnda);
                return;
            }
            catch (Exception ex)
            {
                Log.WriteLogERR(ex);
                return;
            }
        }
        /// <summary>
        /// 用户返回AJAX请求实体 success 是否成功 msg 提示信息 
        /// </summary>
        /// <param name="success"></param>
        /// <param name="msg"></param>
        /// <param name="size"></param>
        protected string JsonStr(bool success, string msg,string size)
        {
            return "{"success":"" + success.ToString().ToLower() + "","msg":"" + msg + "","size":"" + size + ""}";
        }
    }
    
  • 相关阅读:
    浅谈对java中锁的理解
    Spring 4 支持的 Java 8 特性
    【转】Java线程面试题 Top 50
    JVM知识点总览-中高级Java工程师面试必备
    [LeetCode] 195. Tenth Line 第十行
    [LeetCode] 281. Zigzag Iterator 之字形迭代器
    [LeetCode] 324. Wiggle Sort II 摆动排序 II
    [LeetCode] 280. Wiggle Sort 摆动排序
    [LeetCode] 167. Fraction to Recurring Decimal 分数转循环小数
    [LeetCode] 187. Repeated DNA Sequences 求重复的DNA序列
  • 原文地址:https://www.cnblogs.com/cyapi/p/15365778.html
Copyright © 2011-2022 走看看