<%@ WebHandler Language="C#" Class="receive" %>
using System;
using System.Web;
using System.IO;
public class receive : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.Request.HttpMethod.Equals("OPTIONS"))
{
context.Response.ClearContent();
context.Response.AddHeader("Access-Control-Allow-Origin", "http://localhost:61269");
context.Response.AddHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
context.Response.AddHeader("Access-Control-Allow-Headers", "content-type");
context.Response.AddHeader("Access-Control-Max-Age", "30");
context.Response.End();
}
else if (context.Request.HttpMethod.Equals("POST"))
{
var files = context.Request.Files;
for (int i = 0; i )
{
var file = files[i];
var filePath = @"E:\PIC\" + Path.GetFileName(file.FileName);
file.SaveAs(filePath);
}
context.Response.AddHeader("Access-Control-Allow-Origin", "http://localhost:61269");
}
}
public bool IsReusable
{
get
{
return true;
}
}
}