Menu
Woocommerce Menu

Windows安装及密码,后台接受base64的上传图片

0 Comment


 1         #region 配合前端的多张图片上传
 2         #region 上传图片方法
 3         /// <summary>
 4         /// 接口方法
 5         /// </summary>
 6         /// <param name="img">带 data:image/jpeg;base64,的base64的图片</param>
 7         /// <returns>图片路径</returns>
 8         [HttpPost]
 9         public ActionResult GETaddimg2(String img)
10         {
11             if (img == null)
12             {
13                 return Json("空");
14             }
15             else
16             {
17                 return Json(PDUploadImage(img), JsonRequestBehavior.AllowGet);
18             }
19         }
20         #endregion
21         #region 图片转化
22         /// <summary>
23         /// base64 的字符串
24         /// </summary>
25         /// <param name="img"></param>
26         /// <returns>图片转成32的名字</returns>
27         public JsonResult PDUploadImage(string img)
28         {
29             string error = "";
30             return Json(SaveImage("/Upload/Article", img, ref error), JsonRequestBehavior.AllowGet);
31         }
32         #endregion
33         #region 截取data:image/jpeg;base64,提取图片,并保存图片
34         /// <summary>
35         /// 截取data:image/jpeg;base64,提取图片,并保存图片
36         /// </summary>
37         /// <param name="file_name"></param>
38         /// <param name="img_string">base64的字符串</param>
39         /// <param name="error">错误的图片格式</param>
40         /// <returns>路径 + 图片的名称</returns>
41         private string SaveImage(string file_name, string img_string, ref string error)
42         {
43             //try
44             //{
45             string[] img_array = img_string.Split(',');
46             byte[] arr = Convert.FromBase64String(img_array[1]);
47             using (MemoryStream ms = new MemoryStream(arr))
48             {
49                 Bitmap bmp = new Bitmap(ms);
50                 if (img_array[0].ToLower() == "data:image/jpeg;base64")
51                 {
52                     bmp.Save(file_name + ".jpg");
53                     return SetImg(Guid.NewGuid().ToString().Replace('-', 'p').Substring(4), "jpg", arr);
54                 }
55                 else if (img_array[0].ToLower() == "data:image/png;base64")
56                 {
57                     bmp.Save(file_name + ".png");
58                     return SetImg(Guid.NewGuid().ToString().Replace('-', 'p').Substring(4), "png", arr);
59                 }
60                 else if (img_array[0].ToLower() == "data:image/gif;base64")
61                 {
62                     bmp.Save(file_name + ".gif");
63                     return SetImg(Guid.NewGuid().ToString().Replace('-', 'p').Substring(4), "gif", arr);
64                 }
65                 else
66                 {
67                     error = "不支持该文件格式。";
68                     return "错";
69                 }
70             }
71             //}
72             //catch (Exception ex)
73             //{
74             //    error = "生成图片发生错误。" + ex.ToString();
75             //    return "错";
76             //}
77         }
78         #endregion
79         #region 保存图片路径及设置名称
80         /// <summary>
81         /// 保存到文件路径
82         /// </summary>
83         /// <param name="ImgName">保存的文件名称</param>
84         /// <param name="suffix">后缀名</param>
85         /// <param name="arr">base64</param>
86         /// <returns>图片的路径</returns>
87         public string SetImg(string ImgName, string suffix, byte[] arr)
88         {
89             string str3 = System.AppDomain.CurrentDomain.BaseDirectory;//找到相对路径
90             string str4 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;//找到相对路径
91             System.IO.File.WriteAllBytes(str3 + "/Upload/Article/" + ImgName + "." + suffix + "", arr);
92             return "/Upload/Article/" + ImgName + "." + suffix + "";
93         }
94         #endregion
95         #endregion

 

DEVCAPS1.C

 

<appSettings>
  <add key="RedisServer" value="127.0.0.1:6379,password=123456,syncTimeout=3000,abortConnect=false" />
</appSettings>

 

注意标红的地方,配置法规:

获得器械条件的消息

1、 密码限制

  1 //DEVCAPS1.C--Device Capabilities Display Program No.1 (c) Charles Petzold, 1998
  2 #include <Windows.h>
  3 
  4 #define NUMLINES ((int) (sizeof(devcaps) / sizeof(devcaps[0])))
  5 struct  
  6 {
  7     int iIndex;
  8     TCHAR *szLabel;
  9     TCHAR *szDesc;
 10 }
 11 devcaps[] =
 12 {
 13     HORZSIZE,        TEXT("HORZSIZE"),        TEXT("Width in millimeters:"),
 14     VERTSIZE,        TEXT("VERTSIZE"),        TEXT("Height in milimeters:"),
 15     HORZRES,        TEXT("HORZRES"),        TEXT("Width in pixels:"),
 16     VERTRES,        TEXT("VERTRES"),        TEXT("Height in raster lines:"),
 17     BITSPIXEL,        TEXT("BITSPIXEL"),        TEXT("Color bits per pixel:"),
 18     PLANES,            TEXT("PLANES"),            TEXT("Number of color planes:"),
 19     NUMBRUSHES,        TEXT("NUMBRUSHES"),        TEXT("Number of device brushes"),
 20     NUMPENS,        TEXT("NUMPENS"),        TEXT("Number of device pens:"),
 21     NUMMARKERS,        TEXT("NUMMARKERS"),        TEXT("Number of device markers:"),
 22     NUMFONTS,        TEXT("NUMFONTS"),        TEXT("Number of device fonts:"),
 23     NUMCOLORS,        TEXT("NUMCOLORS"),        TEXT("Number of device colors:"),
 24     PDEVICESIZE,    TEXT("PDEVICESIZE"),    TEXT("Size of device structure:"),
 25     ASPECTX,        TEXT("ASPECTX"),        TEXT("Relative width of pixel:"),
 26     ASPECTY,        TEXT("ASPECTY"),        TEXT("Relative height of pixel:"),
 27     ASPECTXY,        TEXT("ASPECTXY"),        TEXT("Relative diagonal of pixel:"),
 28     LOGPIXELSX,        TEXT("LOGPIXELSX"),        TEXT("Horizontal dots per inch:"),
 29     LOGPIXELSY,        TEXT("LOGPIXELSY"),        TEXT("Vertical dots per inch:"),
 30     SIZEPALETTE,    TEXT("SIZEPALETTE"),    TEXT("Number of palette entries:"),
 31     NUMRESERVED,    TEXT("NUMRESERVED"),    TEXT("Reserved palette entries:"),
 32     COLORRES,        TEXT("COLORRES"),        TEXT("Actual color resolution:")
 33 };
 34 
 35 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
 36 
 37 int WINAPI WinMain( __in HINSTANCE hInstance
 38                     , __in_opt HINSTANCE hPrevInstance
 39                     , __in LPSTR lpCmdLine
 40                     , __in int nShowCmd )
 41 {
 42     static TCHAR szAppName[] = TEXT("DevCaps1");
 43     HWND hwnd;
 44     MSG msg;
 45     WNDCLASS wndclass;
 46 
 47     wndclass.style = CS_HREDRAW | CS_VREDRAW;
 48     wndclass.lpfnWndProc = WndProc;
 49     wndclass.cbClsExtra = 0;
 50     wndclass.cbWndExtra = 0;
 51     wndclass.hInstance = hInstance;
 52     wndclass.hIcon= LoadIcon(NULL, IDI_APPLICATION);
 53     wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
 54     wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
 55     wndclass.lpszMenuName = NULL;
 56     wndclass.lpszClassName = szAppName;
 57 
 58     if (!RegisterClass(&wndclass))
 59     {
 60         MessageBox(NULL, TEXT("This program requires Window NT!")
 61             , szAppName, MB_ICONERROR);
 62         return 0;
 63     }
 64 
 65     hwnd = CreateWindow(szAppName, TEXT("Device Capabilities")
 66         , WS_OVERLAPPEDWINDOW
 67         , CW_USEDEFAULT, CW_USEDEFAULT
 68         , CW_USEDEFAULT, CW_USEDEFAULT
 69         , NULL, NULL, hInstance, NULL);
 70 
 71     ShowWindow(hwnd, nShowCmd);
 72     UpdateWindow(hwnd);
 73 
 74     while (GetMessage(&msg, NULL, 0, 0))
 75     {
 76         TranslateMessage(&msg);
 77         DispatchMessage(&msg);
 78     }
 79 
 80     return msg.wParam;
 81 }
 82 
 83 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 84 {
 85     static int cxChar, cxCaps, cyChar;
 86     TCHAR szBuffer[10];
 87     HDC hdc;
 88     int i;
 89     PAINTSTRUCT ps;
 90     TEXTMETRIC tm;
 91 
 92     switch (message)
 93     {
 94     case WM_CREATE:
 95         hdc = GetDC(hwnd);
 96         GetTextMetrics(hdc, &tm);
 97         cxChar = tm.tmAveCharWidth;
 98         cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
 99         cyChar = tm.tmHeight + tm.tmExternalLeading;
100         ReleaseDC(hwnd, hdc);
101         return 0;
102 
103     case WM_PAINT:
104         hdc = BeginPaint(hwnd, &ps);
105         for (i = 0; i != NUMLINES; ++i)
106         {
107             TextOut(hdc, 0, cyChar * i, devcaps[i].szLabel
108                 , lstrlen(devcaps[i].szLabel));
109             TextOut(hdc, 14 * cxCaps, cyChar * i, devcaps[i].szDesc
110                 , lstrlen(devcaps[i].szDesc));
111             SetTextAlign(hdc, TA_RIGHT | TA_TOP);
112             TextOut(hdc, 14 * cxCaps + 35 * cxChar, cyChar * i, szBuffer
113                 , wsprintf(szBuffer, TEXT("%5d"), GetDeviceCaps(hdc, devcaps[i].iIndex)));
114             SetTextAlign(hdc, TA_LEFT | TA_TOP);
115         }
116         EndPaint(hwnd, &ps);
117         return 0;
118 
119     case WM_DESTROY:
120         PostQuitMessage(0);
121         return 0;
122     }
123 
124     return DefWindowProc(hwnd, message, wParam, lParam);
125 }

3、.NET平台下的Web.config文件配置

图片 1图片 2

 图片 3

<appSettings>
  <add key="配置Key名称" value="Redis服务器IP:相应端口,password=设置的访问密码,syncTimeout=同步超时时间单位是这毫秒,abortConnect=在链接不到有效的服务器的时候是否
会创建一个链接实例" />
</appSettings>

修改为 <processModel autoConfig=”false”
maxIoThreads=”250″ minIoThreads=”50″/>

1)、 改为“# bind 127.0.0.1”则是不限量IP访谈(前边加符号 #
),假诺本机有八个IP,则应用大肆四个IP均能访谈;

  基本格式如下:

 

缓存音讯平日相比较灵活,通过设置密码可有效降低缓存数据外泄恐怕。设置如下:

标签:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章

网站地图xml地图