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 + ""}";
}
}